scheduling a php page to run every hour....
Posted: Fri Mar 18, 2005 9:58 am
by Burrito
I just created a report that I need to have run every hour. My plan was to use the windows task scheduler and just the PHP CLI, but I just found out as I was trying to schedule my task that the smallest increments I can do are days (windows 2000 server).
I've heard the term cron job tossed around in here a lot but I've always just associated that with *nix. Is it something that can be done with windows? If not is there some other alternative that I can do to schedule a php page to be run every hour?
please advise.
thx,
Burr
Posted: Fri Mar 18, 2005 12:49 pm
by Burrito
well I'd rather not have to leave someone logged in to the server with a browser window open.
Isn't there some kind of cron for windows?
I'm pretty sure I've heard of it...the other alternative we've thought of would be to just install automate on there to do it...but wanna avoid that if possible.
Posted: Fri Mar 18, 2005 12:54 pm
by infolock
cron jobs are exactly what you need to use. you should, however, be able to do it in windows server 2000 as well.. i was able to before i moved on to 2k3 enterprise
questions
Posted: Fri Mar 18, 2005 6:33 pm
by windforceus
ah, i want to use cron but i am a newbie, can someone give a better tutorial?
Posted: Fri Apr 08, 2005 12:41 pm
by Burrito
Sami, I am having to do this again (on another system) and so I figured I'd try using the task scheduler built into windows (using your suggestion), and I am running into an issue.
I have the repeat task check box checked and selected every: 1 hours. when I click ok, it tells me that the duration must be LONGER than the repitition interval. That seems counterintuitive to me. It won't let me "save" it unless I make the duration 1:01 or greater. This doesn't make sense to me, wouldn't that make the duration of the task overlap the next scheduled task? It would make sense to me if the duration had to be LESS, but not more.
If someone could explain the logic behind this, I'd really appreciate it.
ty,
Burrito
Why not use the AT command?
Posted: Sun Apr 10, 2005 12:59 am
by spsellars
I say dump the GUI Task Scheduler and use the AT command in a command prompt. (Assuming your script can be run as local service.)
Copy the following at commands to file called schedule.bat (or whatever you want), obviously change the script and php location to match your setup, and run the batch file from a command prompt. After that your script should run on the hour every hour. (Make changes to the time as necessary too.) This is what I use to schedule updates for clients on my network, much easier this way. One thing you may want to look into is Priado Blender (spelling?), it's free and bundles your script into an exe with the php interpreter, I usually do that for my scheduled php scripts as I change my web server php version every time a new version comes out, and that can lead to surprises in your scheduled scripts.
----------- Copy everything BELOW this line to .bat file --------------
at 0:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 1:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 2:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 3:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 4:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 5:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 6:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 7:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 8:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 9:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 10:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 11:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 12:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 13:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 14:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 15:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 16:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 17:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 18:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 19:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 20:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 21:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 22:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"
at 23:00 /EVERY:M,T,W,Th,F,S,Su "c:\php\php.exe c:\mydir\myscript.php"