milosh012 Posted May 22, 2009 Share Posted May 22, 2009 Hello everybody! I'm relative new to php, and i have one question. How can I run php script at specified time (HH:MM:SS)? I have heard for cron job, but he can execute my script with precision of minute (HH:MM), but I need to run script with precision of second! Does anybody have any idea? Thanks a lot! Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/ Share on other sites More sharing options...
Daniel0 Posted May 22, 2009 Share Posted May 22, 2009 You should be able to do that with cron jobs. Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/#findComment-840185 Share on other sites More sharing options...
milosh012 Posted May 22, 2009 Author Share Posted May 22, 2009 You should be able to do that with cron jobs. I have check, and cron job can only do this with precision of minute... is there any other way? Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/#findComment-840191 Share on other sites More sharing options...
Daniel0 Posted May 22, 2009 Share Posted May 22, 2009 You didn't check very thoroughly then: Step values can be used in conjunction with ranges. Following a range with ``/<number>'' specifies skips of the number's value through the range. For example' date=' ``0-23/2'' can be used in the hours field to specify command execution every other hour (the alternative in the V7 standard is ``0,2,4,6,8,10,12,14,16,18,20,22''). Steps are also permitted after an asterisk, so if you want to say ``every two hours'', just use ``*/2''.[/quote'] E.g. 10/15 3 * * * = every day at 3:10:15 AM. Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/#findComment-840204 Share on other sites More sharing options...
milosh012 Posted May 24, 2009 Author Share Posted May 24, 2009 Yeah, but that is not helping me with the desired precision (seconds). Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/#findComment-841399 Share on other sites More sharing options...
fantomel Posted May 24, 2009 Share Posted May 24, 2009 from the example i`ve seen it`s what you want to run a certain php script at a given hour minute and second i think the problem you are having is that you don`t know what you want Daniel0 gave you the perfect example including a website and an explanation Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/#findComment-841404 Share on other sites More sharing options...
MadTechie Posted May 24, 2009 Share Posted May 24, 2009 As your new to PHP and cron is technically a unix function, i thouight i'll give you some php to solved it this script will run for 1 hour and allow you set any condition you like that gets checked every second, so you could run it every hour on the hour via cron jobs <?php set_time_limit(0); $endtime = time()+(1*60*60); while(time()<$endtime) { /* if(condition) //time etc { do something } */ sleep(1); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/#findComment-841428 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.