Creating cron jobs in Windows 8 and Server 2012 (or any version of Windows)

I recently made the switch from a Linux LAMP server to a Windows Server 2012.  It didn’t take me too long to figure out I forgot to transfer my cron jobs for my PHP pages. I went to start the transfer and I soon realized that Windows does not support cron jobs. However, I did find the Windows version of Cron jobs. Below is what I did to create these cron jobs so my PHP crons will continue run on scheduale. This trick will really work in all versions of Windows, but you must get to it different methods.

Open the Windows start menu and type in “Schedule Tasks”. This will open the Task Scheduler.  After that click Create Task (I would not suggest using basic task, as it is too basic for cron jobs).

Click Create Task..
Task Scheduler

This will open a window that allows you to create a new “Cron Job” in Windows Server 2012 or Windows 8.1.

Name: This is a easy way for you to remember what that tasks does. You can enter anything.

Description: Just a more in depth description for you to remember what it is.

User Account: I would suggest using a full privileged account so that your cron jobs can create and modify files if it needs to. But I would also suggest using a account dedicated to Cron jobs so that you can revoke permissions any time you need to!

Due to the nature of a website, I would definitely check “Run when user is logged in or not” and leave do not store password (This can throw an XML invalid error if you leave this unchecked and a password is required)

And I would also check “Run with Highest Privileges”

General Tab for Task Scheduler for my website
General Tab for Task Scheduler for my website

After that, Click “Trigger” and “Add new”:

Add New Trigger
Add New Trigger

To run a “Cron Job” task that runs more than once a day, Click Daily task. Recure daily, and repeat task every (How often you want the task to run. You can type in other options in this field than what is given) and be sure to click enabled. After that click Okay and click the tab “Actions” and New…

New action - Task Scheduler
New action – Task Scheduler

Set program/Script to the PHP.exe (default is seen in picture) and arguments as the php file you want to run. Be sure to use “” if you have spaces in the path. I would suggest using them either way as a rule of thumb.

Now you can create “Cron Jobs” in Windows! Comment if you have any questions or suggestions!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.