How To Run Linux Style Cron Jobs on Windows

logoimagetime   How To Run Linux Style Cron Jobs on WindowsEver wanted to connect/disconnect the Internet connection at particular times? Want to perform disk defragmentation on weekends when you are not working on your computer? Want to perform backups on 27th of each month?

If you ever wondered how you could achieve that Linux style cron jobs on Windows and tried using the Windows task scheduler you have probably given up hope and have multiple entries to run the same task. On the other hand if you have used the Linux Cron utility you’ll know the power it offers. Bringing similar powers and options to Windows is Z-Cron.

Download

You can download Z-Cron for free here. The download is a zip file, extract and run the setup.

How to Use

Once Z-Cron has been set up, you can begin scheduling tasks with great power and ease. Lets say you keep all your torrent files in one directory and you want to be able to load all the torrent files in that directory in your torrent client for downloading, automatically at 2am on Saturdays and Tuesdays (for whatever reason, here in India we have some broadband plans where data transfer doesn’t count towards the bandwidth cap between 2 am – 8 am, so you can use the following example and change it according to your needs).

Let’s walk through the process:

1. I am using µtorrent in this example.  If you use any other torrent client you would have to find the command line options/parameters for your client. For µtorrent it is

µtorrent.exe /directory “<torrent save path>” “<path to torrent file>”

2. Since we want to add all the torrents in a particular directory to the download queue you would have to create a batch file. I won’t get into the details here but here is what you add to the batch file (I am looping through all torrent files and adding them to µtorrent):

ECHO OFF
cd c:\Torrents
FOR %%X IN (*.torrent) DO “C:\Program Files\µtorrent\µtorrent.exe” /directory “D:\Torrent_Downloads” c:\Torrents\%%X

Where C:\Torrents is where I would store .torrent files and D:\Torrent_Downloads is where I want the downloads to be stored. Be careful while using spaces in names of folders or files, it may break the batch file code.

3. Save this file as torrents.bat

4. Start Z-Cron, Click on task (this allows you to create/edit existing tasks)

addtask   How To Run Linux Style Cron Jobs on Windows

5. This should open up the Job Settings Window like below. In here you can choose the program/batch file/commands to run and pass arguments to them. Since we already created a batch file in steps 1,2 and 3 we will choose that file here, name our task and provide some description.

taskdesc   How To Run Linux Style Cron Jobs on Windows

6. Click on the scheduler tab and this is where you get the control over scheduling that you can’t even imagine to get with the default Windows Task Scheduler. The screen looks like this:

scheduler   How To Run Linux Style Cron Jobs on Windows

You can choose to schedule tasks by weeks or months. Check the Weekday under “Period” and you will get the weekly scheduler. Check Tuesday and Saturday.

If however you want greater control you can schedule for specific dates by choosing “Month” as period, which makes it look like this:

scheduler month   How To Run Linux Style Cron Jobs on Windows

You can now do things like making the task run on 27th of every month, last Week of every month, or all Tuesdays of every month, or simply run on 27th February or any other day.

7. So far so good, we have chosen the days we want the task to run, now for the time. Click on scheduler button to bring up a screen like the following:

newschedule   How To Run Linux Style Cron Jobs on Windows

Hover over the check boxes and see the time change at the bottom, check the appropriate check box, you can select multiple checkboxes to run the task repeatedly.

8. For our torrent download example the screens look like this (remember we want to run it at 2 am on Saturdays and Tuesdays)

torrent1   How To Run Linux Style Cron Jobs on Windows
newschedule   How To Run Linux Style Cron Jobs on Windows

That’s it we have scheduled the task to run at 2 am on Tuesdays and Saturdays (notice the calendar on right hand side).

In addition to the control you get in scheduling tasks, you can also use Z-Cron’s built in commands to dial up your connection, move files/ directories, sound alarms, kill processes, monitor programs and many more things effectively removing tedious steps 1, 2 and 3. However if you need something custom, like the example above, you will have hack around a bit!

built ins   How To Run Linux Style Cron Jobs on Windows

So how do you like Z-Cron? Do you know of other similar utilities for Windows? Can you think of more constructive ways to use Z-Cron? Share with us in the comments!

The comments were closed because the article is more than 180 days old.

If you have any questions related to what's mentioned in the article or need help with any computer issue, ask it on MakeUseOf Answers—We and our community will be more than happy to help.

5 Comments -

0 votes

BobCFC

Cron is so powerful. Many times I want to go to bed at 4am but I have a download that still has 15mins to go so I just type something like

sudo halt 4:30

And I can goto sleep knowing that my system will shut itself down.

0 votes

Alvin Finn

I’ve been using nnCron for many years and it’s always been flawless. Unlike Z-Cron, nnCron has no GUI as it uses the standard unix crontab format. I think this is actually easier because once you take a few minutes to understand the crontab format, setting up a new job is trivial. I don’t know about the memory footprint of Z-Cron, but nnCron is extremely lightweight and stable.

0 votes

lainwired

Wow. nice tip. i need to check out hat z-cron

0 votes

Peter

… or you could use the built-in task scheduler of Windows…