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.

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

3 Answers

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

link|improve this answer
feedback

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)

link|improve this answer
feedback

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
link|improve this answer
feedback

Your Answer

 
or
required, but never shown