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
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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.