besly98 Posted August 5, 2009 Share Posted August 5, 2009 Hi All, I wanted to run a script at midnight every day (00:00:00 hrs my server time). Can i simply do an if statment based on the server time, to say if the time is midnight.. do this.... (and will it run witout the page being loaded up.. just go in the background?) thanks for your help Quote Link to comment Share on other sites More sharing options...
tobimichigan Posted August 5, 2009 Share Posted August 5, 2009 Have u tried echoing the session page? Quote Link to comment Share on other sites More sharing options...
besly98 Posted August 5, 2009 Author Share Posted August 5, 2009 what do you mean? i have not set anythign up, as im not 100% sure what to do. as i said, if i can simple use a if statment to say if the time is midnight run this script..... but i need it to run in the background. Quote Link to comment Share on other sites More sharing options...
Zepo. Posted August 5, 2009 Share Posted August 5, 2009 In short, yes you can do that. A simple if/them statement would work. I'm not sure about this one but i think you might be able to setup a cron if you use cpanel to do the same thing as the if/then statement. Quote Link to comment Share on other sites More sharing options...
besly98 Posted August 5, 2009 Author Share Posted August 5, 2009 cool. thanks. and this will run in the background, and i wont need to touch anything?> Quote Link to comment Share on other sites More sharing options...
Zepo. Posted August 5, 2009 Share Posted August 5, 2009 Yup. Why not try it Quote Link to comment Share on other sites More sharing options...
besly98 Posted August 5, 2009 Author Share Posted August 5, 2009 thanks and this is the server time isnt it? <? echo time(); ?> Quote Link to comment Share on other sites More sharing options...
Zepo. Posted August 5, 2009 Share Posted August 5, 2009 Yes. Or you can use $_SERVER['REQUEST_TIME']. The only problem with this that i just thought of is someone would have to load that page right on that millisecond to run that statement, i think the cron job would be a better alternative. Read: http://www.modwest.com/help/kb5-125.html Quote Link to comment Share on other sites More sharing options...
besly98 Posted August 5, 2009 Author Share Posted August 5, 2009 oh. i thought it would run in the background? without the page being loaded? Quote Link to comment Share on other sites More sharing options...
Zepo. Posted August 5, 2009 Share Posted August 5, 2009 Sorry, i misread it. You would need to call the page at the right time. Check the link above. Quote Link to comment Share on other sites More sharing options...
besly98 Posted August 5, 2009 Author Share Posted August 5, 2009 it looks confusing lol Quote Link to comment Share on other sites More sharing options...
trq Posted August 5, 2009 Share Posted August 5, 2009 Scripts don't run themselves, you need to use your server operating systems scheduler. Linux has cron, windows has task scheduler. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.