1834926 Members
2308 Online
110071 Solutions
New Discussion

Re: Cron question

 
SOLVED
Go to solution
dictum9
Super Advisor

Cron question

How do I cron a script to run every 4 minutes?

8 REPLIES 8
Sundar_7
Honored Contributor
Solution

Re: Cron question

2 ways to do it

1) You will have to list the minutes explictly in the cron like this

0,4,8,12,16,20.....56 * * * *

2) Control the execution programmatically using a wrapper.
Learn What to do ,How to do and more importantly When to do ?
A. Clay Stephenson
Acclaimed Contributor

Re: Cron question

0,4,8,12,16,20,24,28,32,36,40,44,48,52,56 * * * * /xxx/yyy/mytask.sh
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: Cron question

By the way, did you bother to do a "man crontab" before you asked this question. That would tell you that you would do something like this (as well as answer your question):

crontab -l > myfile
edit myfile and make your changes
crontab < myfile
If it ain't broke, I can fix that.
James R. Ferguson
Acclaimed Contributor

Re: Cron question

Hi:

Look at the manpages for 'crontab' to see that a comma-delimited list is what you want:

# 0,4,8,12,16,20,24,28,32,36,40,44,48,52,56 * * * * /etc/mything

...would run /etc/mything every 4-minutes of every hour of every day of every month.

Regards!

...JRF...
sachit patil
Regular Advisor

Re: Cron question

#crontab -e
make enrty
0,4,8,12,16,20,24,28,32,36,40,44,48,52,56 * * * * script.sh

DO this
Steven E. Protter
Exalted Contributor

Re: Cron question

Shalom etc,

Note that Linux has initiated some conventions that Unix does not support. The */4 convention you might find on a Linux support board will generally not work.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Arturo Galbiati
Esteemed Contributor

Re: Cron question

0,4,8,12,16,20,24,28,32,36,40,44,48,52,56 * * * * /full_path/your_script 1>out 2>err

Note that if you not redirect the oupit/error of the script this is send to the user email and you can see it by elm.

HTH,
Art
Yogeeraj_1
Honored Contributor

Re: Cron question

hi,
see also:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=1114824

kind regards
yogeeraj
No person was ever honoured for what he received. Honour has been the reward for what he gave (clavin coolidge)