1827995 Members
2705 Online
109973 Solutions
New Discussion

Crontab

 
SOLVED
Go to solution
george_114
Advisor

Crontab

my crontab's list is below:
#crontab -l
15,30,45,59 10-11 * * * /u/pinguin/bin/ochkdb.sh

Why my cronjob still running at 11.15 and so on ??
6 REPLIES 6
Stuart Browne
Honored Contributor
Solution

Re: Crontab

That crontab says to run at the following times:

10:15
10:30
10:45
10:59
11:15
11:30
11:45
11:59

everyday. When did you want it to run? just within the 10 o'clock range, every 15 minutes? Why not use:

0,15,30,45 10 * * * /u/pinguin/bin/ochkdb.sh

?

Or better yet, as it's probably got a non-archaic cron daemon:

*/15 10 * * * /usr/pinguin/bin/ochkdb.sh

This doesn't check to see if the program was running from the previous invocation of course. If it takes longer than 15 minutes to run, maybe you should throw some starts in ochkdb.sh instead.
One long-haired git at your service...
Chris DePetro
Occasional Advisor

Re: Crontab

When specifying a range for your hours, the numbers are inclusive. So by using "10-11", your script will run at: 10:15, 10:30, 10:45, 10:59, 11:15, 11:30, 11:45, and 11:59. If this is not what you want, change "10-11" to only "10".
man 5 crontab - explains in detail.
Hope this helps.
george_114
Advisor

Re: Crontab

How to write the crontab script if i want to run my cron job every 15 minute except at 4-5 am ???
Stuart Browne
Honored Contributor

Re: Crontab

*/15 0-3,6-23 * * *

I'm reasonably certain that you can't wrap the 24 hour barrier (i.e. '6-3'), thus the two ranged-hours.
One long-haired git at your service...
Gerald V. Livingston II
Occasional Contributor

Re: Crontab


How to write the crontab script if i want to run my cron job every 15 minute except at 4-5 am ???


I read that as being he doesn't want it running between the hours of 0400 and 0500 -- ie. no run from 04:00:00 - 04:59:59. So, you left an hour out of your range.

*/15 0-3,6-23 * * *

should be

*/15 0-3,5-23 * * *

to include the 5am to 5:59am time frame.

man 5 crontab doesn't say anything about wrapping across midnight and I assume you are correct on that matter BECAUSE it isn't mentioned.

G
Stuart Browne
Honored Contributor

Re: Crontab

Good pick up Gerald, I did over-look that. My apologies George.
One long-haired git at your service...