I recently made the switch from a Linux LAMP server to a Windows Server 2016. 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 schedule. 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 "Scheduled 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).
Task Scheduler
This will open a window that allows you to create a new "Cron Job" in Windows Server 2016 or Windows 10.
Name: This is an easy way for you to remember what that task 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 an 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 MafiaStreetWars.com
After that, Click "Trigger" and "Add new":
Add New Trigger
To run a "Cron Job" task that runs more than once a day, Click Daily task. Recure daily, and repeat the 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
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!
Originally posted at https://moreabout.tech/creating-cron-jobs-in-windows-10-and-windows-server-2016/
Thanks for this. Now I can actually help one of the wider communities asking for greater Windows support; seriously. PHP applications on Windows need more love.
Hi! I am a robot. I just upvoted you! I found similar content that readers might be interested in:
https://moreabout.tech/creating-cron-jobs-in-windows-10-and-windows-server-2016/