|Crontab Syntax Help|
Hours of the day
| 3:03 pm on Oct 11, 2006 (gmt 0)|
Hi, I am wondering if this is possible... I want to run a cron job for the first 1-12 hours of the day every 5 minutes, but also for the 21st to 24th hour of the day. It may sound stupid but it makes sense with what i'm doing. Does the below crontab look right? I know */5 updates every 5 minutes but does the 1-12,21-24 part look correct?
*/5 1-12,21-24 * * *
| 4:50 pm on Oct 11, 2006 (gmt 0)|
It looks good except for one small issue. Midnight, in a cron time is 0. So the 1-12,21-24 should be 1-12,21-0.
As a side note: does anyone know if 21-12 would work instead of 1-12,21-0?
| 9:26 am on Oct 12, 2006 (gmt 0)|
Both 1-12,21-0 or 21-12 don't work. After trying to save it, it says "bad hour: errors in crontab file, can't install".
It looks like the only way is the long way:
*/5 1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,0 * * *
Doing it the long way there's no errors.
| 3:26 pm on Oct 12, 2006 (gmt 0)|
What you want is:
*/5 0-12,21-23 * * *
That's the hour of midnight through the hour of noon, plus the hour of 9pm through the hour of 11pm, all inclusive.
| 2:54 am on Oct 13, 2006 (gmt 0)|
The logic of */5 0-12,21-23 * * * looks right but I get the error message saying "bad hour: errors in crontab file, can't install".