run a script every 4 hours with task scheduler
Asked Answered
L

2

53

I have windows 2008 task scheduler I set up a PHP script to run like this

C:\php\php.exe -f etc...

In windows task scheduler I can only schedule daily or hourly how can I configure it to run every 4 hours?

Lally answered 20/1, 2014 at 17:41 Comment(0)
N
158

In Windows Server 2008/2008R2 you can set task to repeat every number of hours you want, corresponding drop down menu just present you with 1 hour option to select, but you can type in any number of hours you need (see screenshot below).

enter image description here

Namedropping answered 21/1, 2014 at 7:43 Comment(1)
You can also enter fractions of an hour by converting to minutes. E.g. you can't enter 3.5 hours but you can enter 210 minutes.Verniavernice
S
2

You could just set it up to run every hour, and at the beginning of the PHP script, check the current time, and exit if the current hour modulus 4 wasn't zero.

Where it says "repeat task every", you may also just be able to change "1 hour" to "4 hours" (it's not in the dropdown, so just type it in). You can do this in Windows 7, I'm not sure about Windows Server 2008.

Saccharometer answered 20/1, 2014 at 17:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.