homepage Welcome to WebmasterWorld Guest from 54.166.53.169
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
Forum Library, Charter, Moderators: bakedjake

Linux, Unix, and *nix like Operating Systems Forum

    
Crontab Syntax Help
Hours of the day
joshm

5+ Year Member



 
Msg#: 3116898 posted 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 * * *

 

jezra

10+ Year Member



 
Msg#: 3116898 posted 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?

joshm

5+ Year Member



 
Msg#: 3116898 posted 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.

mcavic

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 3116898 posted 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.

joshm

5+ Year Member



 
Msg#: 3116898 posted 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".

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Hardware and OS Related Technologies / Linux, Unix, and *nix like Operating Systems
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved