Go Premium for a chance to win a PS4. Enter to Win


Hourly Cron job for windows

Posted on 2003-12-10
Medium Priority
Last Modified: 2012-08-13
How can I schedule a cron job to run every hour?

I'd like to be able to be more sophisticated and run this job once every hour during working hours on monday through friday but that'll do for now
Question by:jayrod
LVL 63

Expert Comment

by:☠ MASQ ☠
ID: 9915372
Host dependent but, for example ...

Via the "crontab" command from the shell.
crontab -l will show you your currently set up cron jobs on the server.

crontab -r will delete your current cron jobs.

crontab -e will allow you to add or edit your current cron jobs by using your default text editor to edit your "crontab file".

Your crontab includes all the cron jobs you'd like, with one cron entry per line. A cron entry looks like this:

45 2 * * *     /home/user/script.pl

The first number is the minute of the hour for the command to run on.
The second number is the hour of the day for the command to run on.
The third number is the day of the month for the command to run on.
The fourth number is the month of the year for the command to run on.
The fifth number is the day of the week for the command to run on.
Here are some examples to help you learn the syntax for the numbers:

32 * * * * : will be run every hour on the 32nd minute.
12,42 * * * * : will be run twice an hour on the 12th and 42nd minutes.
*/15 */2 * * *: will be run at 0:00, 0:15, 0:30, 0:45, 2:00, 2:15, 2:30, ...
43 18 * * 7: will be run at 6:43pm every Sunday.

Author Comment

ID: 9915419
sorry I needed this on a windows platform.. sorry for wasteing your brain cycles.
LVL 63

Expert Comment

by:☠ MASQ ☠
ID: 9915533
Sorry, crons are strictly linux. Could you put it into scheduler?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 19

Accepted Solution

Dexstar earned 1600 total points
ID: 9915875

> I'd like to be able to be more sophisticated and run this job once every hour
> during working hours on monday through friday but that'll do for now

In Windows, it is called the AT command.  "AT /?" at a command line to see the parameters...  Say you want to run "C:\DoIt.bat" on the computer SOMESERVER every hour Monday through Friday.  You'll have to issue these commands:

     AT \\SOMESERVER 8:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 9:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 10:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 11:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 12:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 13:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 14:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 15:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 16:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 17:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"
     AT \\SOMESERVER 18:00 /EVERY:Monday,Tuesday,Wednesday,Thursday,Friday "C:\DoIt.bat"

Let me know if you have any problems.

Hope That Helps,

Assisted Solution

e_sandrs earned 200 total points
ID: 9916353
Great info from Dex already.  I'd just expand to note, if this helps you, that on WinXP and/or Win2k3 Server you can use the command "SCHTASKS" instead of "AT".  On Win2k Server, you only have "AT".

Nice, printable help files are available from Start -> Help, searching for "command at", for example.

Eric Sanders
-Just some guy on a board.
LVL 24

Assisted Solution

shivsa earned 200 total points
ID: 9916402
Windows has a builtin "AT" command with similar functionality.

The Windows resource kit contains a GUI version called "WinAt". u may find it very helpful.

this is a example to run job at 8:00 am in the morning for monday to friday.

at 8:00 /every:Mo,Tu,We,Th,Fr, do_something

u may put in a for look in a bat file or copy the same file for wach hour as Dex suggested above.
Once u are done You have to set the "Schedule" service to start automatically though because it does not start by default.

Start > Settings > Control Panel > Services > Highlight Schedule > Click Start > Now Click Startup > Click Automatic > OK
Note you can configure it to be automatically started when you boot your machine.

also winat is quite good.u can download it from here.
LVL 10

Expert Comment

ID: 9919221
it is simple go to Programs - accessories - system tools - Scheduled Tasks
in that u can run the wizard or do it manually to select the job u want to run  , select advanced to schedule every hour . There are whole lot of options to set there !


Author Comment

ID: 9920117
Thanks for all of the help you all :)

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction How to create multiboot configuration with XP\Vista and Windows 7 on it? And most important question - how to do this correctly so not to have any kind of nightmares we get when system gets screwed? First of all one should realize t…
Sometimes a user will call me frantically, explaining that something has gone wrong and they have tried everything (read - they have messed it up more and now need someone to clean up) and it still does no good, can I help them?!  Usually the standa…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question