scheduling a php page to run every hour....
Moderator: General Moderators
scheduling a php page to run every hour....
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
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
mainly at midnight every day. it mainly just ran my backup of a media server log file every night and then executed another php script to generate the reports.
edit: sorry i misunderstood your original question. let me reitterate :
yes, for a one time thing, task scheduler. but it also has options to run hourly (http://support.microsoft.com/?kbid=226795)
yes for a hourly run, cron jobs.
edit: sorry i misunderstood your original question. let me reitterate :
yes, for a one time thing, task scheduler. but it also has options to run hourly (http://support.microsoft.com/?kbid=226795)
yes for a hourly run, cron jobs.
You can run them in smaller increments than hours/days.
See the link infolock posted for more details.Modifying a Scheduled Task
1. Click Start, point to Settings, and then click Control Panel.
2. Double-click Scheduled Tasks.
3. Right-click the task you want to modify, and then click Properties. If no task is listed, double-click Add Scheduled Task to start the Scheduled Task Wizard.
NOTE: If you use the Scheduled Task Wizard, click the Open advanced properties for this task when I click Finish check box select it, and then click Finish to continue.
4. Click the Schedule tab, and then click Advanced.
5. Click the Repeat task check box to select it, and then specify the number of minutes or hours you want the task to be repeated.
6. Click OK, and then click OK again.
-
windforceus
- Forum Newbie
- Posts: 23
- Joined: Tue Mar 15, 2005 12:40 pm
questions
ah, i want to use cron but i am a newbie, can someone give a better tutorial?
the link I posted above (http://www.kalab.com/freeware/cron/cron.htm) has some pretty good examples of how to do it.
that's what I ended up using and it works fine...wish I'd have known about the windows task mgr thingy sooner
that's what I ended up using and it works fine...wish I'd have known about the windows task mgr thingy sooner
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
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?
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"
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"