Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm editing a crontab for a job that I want to run every minute but only between the hours of 10pm and 2am. Outside this time I'd like it to run every 10 minutes, I'm not sure if this is possible though.

Any help appreciated, thanks.

share|improve this question
    
figured this out: */1 22-2 * * * and */10 2-22 * * * –  Darryl Jul 15 '10 at 11:58
add comment

3 Answers

It would probably be best to have it a 2 separate jobs, one for each hourly group

* 22-23,0-2 * * * command
*/10 2-22 * * * command
share|improve this answer
add comment

It's easiest to do in two lines.

* 22-23,0-2 * * * command
*/10 2-22 * * * command

This might be specific syntax for vixie cron, though. Check man 5 crontab

share|improve this answer
add comment

Yes, that is possible. Taken from crontab(5):

Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ``hours'' entry specifies execution at hours 8, 9, 10 and 11.

Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: 1,2,5,9'', 0-4,8-12''.

(Assuming Vixie Cron)

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.