Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

run a script every 4 hours with task scheduler

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?

like image 470
jim smith Avatar asked Jan 20 '14 17:01

jim smith


People also ask

How do I set Task Scheduler every hour?

To set the script to run hourly, we select the 'Repeat task…' option and enable it. We select the '1 hour' option, indicating that we wish for the task to execute on an hourly basis, and select the duration as indefinite under the duration option.

How do I schedule a batch file to run every hour?

Step 1: Create a batch file you wish to run and place it under a folder where you have enough permissions, for example, under C drive. Step 2: Click on Start and under search, type in Task, and click open Task Scheduler. Step 3: Select Create Basic Task from the Action pane on the right of the window.


2 Answers

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

like image 129
Mikhail Avatar answered Oct 04 '22 05:10

Mikhail


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.

like image 44
Gerrat Avatar answered Oct 04 '22 05:10

Gerrat