Solved

Hourly Cron job for windows

Posted on 2003-12-10
8
2,296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 62

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.
0
 
LVL 3

Author Comment

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

Expert Comment

by:☠ MASQ ☠
ID: 9915533
Sorry, crons are strictly linux. Could you put it into scheduler?
0
Industry Leaders: 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

by:
Dexstar earned 400 total points
ID: 9915875
@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
 
LVL 5

Assisted Solution

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

Assisted Solution

by:shivsa
shivsa earned 50 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.
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
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 !

 
0
 
LVL 3

Author Comment

by:jayrod
ID: 9920117
Thanks for all of the help you all :)
0

Featured Post

Technology Partners: 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!

Question has a verified solution.

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

Windows 7 does not have the best desktop search built in. This is something Windows 7 users have struggled with. You type something in, and your search results don’t always match what you are looking for, or it doesn’t actually work at all. There ar…
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
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.

752 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