Jump to content

Run PHP Script at specified time (HH:MM:SS)


milosh012

Recommended Posts

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!

Link to comment
https://forums.phpfreaks.com/topic/159305-run-php-script-at-specified-time-hhmmss/
Share on other sites

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.

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);
}
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.