Categories
Uncategorized

Add new cron job on Windows 2008 Server using Task Scheduler

I’ve been working recently on a windows 2008 server and i needed to setup a cron job. Well turns out that windows doesn’t have a cron utility as in Linux world, but there is this Task Scheduler. When trying to find it in Control Panel and the Management Console i discovered that my user had no rights to this utility, but turns out that you can still use it if you run it in CLI (cmd.exe that is)

Open the cms by going to Start->Run and typing cmd.exe then Enter

# to find more about task scheduler:
schtasks /?

# to find more about adding new tasks
schtasks /create /?

# to actually add a new task that runs every hour
schtasks /create /tn "My Cron Job" /tr "C:\PHP\php.exe -f http://www.example.com/cron.php" /sc hourly

# create a task to run every 5 minutes
schtasks /create /tn "My Cron Job" /tr "C:\PHP\php.exe -f http://www.example.com/cron.php" /sc minute /mo 5

Leave a Reply

Your email address will not be published. Required fields are marked *

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