Solved

Hourly Cron job for windows

Posted on 2003-12-10
8
2,291 Views
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
0
Comment
Question by:jayrod
8 Comments
 
LVL 62

Expert Comment

by:☠ MASQ ☠
Comment Utility
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.
0
 
LVL 3

Author Comment

by:jayrod
Comment Utility
sorry I needed this on a windows platform.. sorry for wasteing your brain cycles.
0
 
LVL 62

Expert Comment

by:☠ MASQ ☠
Comment Utility
Sorry, crons are strictly linux. Could you put it into scheduler?
0
 
LVL 19

Accepted Solution

by:
Dexstar earned 400 total points
Comment Utility
@jayrod:

> 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,
Dex*
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 5

Assisted Solution

by:e_sandrs
e_sandrs earned 50 total points
Comment Utility
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.
0
 
LVL 24

Assisted Solution

by:shivsa
shivsa earned 50 total points
Comment Utility
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.
tp.etl.go.jp/oldpub/windows/win32app/winat.exe
ftp.nasda.go.jp/pub/OS/ms-Windows/win32app/winat.exe
ftp.etl.go.jp/pub/windows/win32app/winat.exe
-----------
 
0
 
LVL 10

Expert Comment

by:anupnellip
Comment Utility
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 !

 
0
 
LVL 3

Author Comment

by:jayrod
Comment Utility
Thanks for all of the help you all :)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Occasionally Windows/Microsoft Updates will fail to update. We have found a code that will delete all temporary files and re-register all dll's related to Windows/Microsoft Updates! This works 99% of the time to get the updates working again! The…
In a recent article here at Experts Exchange (http://www.experts-exchange.com/articles/18880/PaperPort-14-in-Windows-10-A-First-Look.html), I discussed my nine-month sandbox testing of the Windows 10 Technical Preview, specifically with respect to r…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now