I have a question about scheduling tasks.
If I have a task scheduled on a PHP page, but that page is never called/referenced, would it still run at the scheduled time?
I have a question about scheduling tasks.
If I have a task scheduled on a PHP page, but that page is never called/referenced, would it still run at the scheduled time?
There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.
How is it "scheduled"?
For a script to run, someone/thing has to envoke it. Called as a web page, run by the cron daemon, or called from another page/script.
Nothing is always absolutely so.
To this effect:PHP Code:$curDate = date('h');
$dateToRun = "12";
$run = 1;
if($curDate == $dateToRun && $run == 1) {
# ... Run task ...
# ... Set run to 0
}
Last edited by as4s1n; 04-12-2010 at 11:56 AM.
There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.
There's nothing there to schedule a task -- all that code will do is keep the code from running except between midnight and one AM and noon and one PM if something else calls your PHP page. The code may never run, or it may run multiple times.
What you need to do is remove the time-sensitive code and set up a cron job to launch the PHP script instead. You can start by looking at this tutorial.
“Beware of bugs in the above code; I have only proved it correct, not tried it.” --Donald Knuth
"It was as if its architects were given a perfectly good hammer and gleefully replied, 'neat! With this hammer, we can build a tool that can pound in nails.'" -- Alex Papadimoulis (on TheDailyWTF.com)
Oh, OK.
BTW: Thanks for the tutorial.
There is no such thing as a "stupid question," there are only "stupid people" who don't ask them.