Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I set a cron to run every 2 hours between 8 am and 5 pm for example? Is this possible?

share|improve this question

migrated from stackoverflow.com Apr 11 '12 at 23:53

This question came from our site for professional and enthusiast programmers.

    
Please search for such things on Google... –  evotopid Apr 11 '12 at 17:34
5  
please read the question, it's not in Google... it's not a normal every 2 hours cron, it's every 2 hours between 8 and 5... –  luqita Apr 11 '12 at 17:41
2  
I searched Google and it brought me here! Thanks for the question/answer it was exactly what I was looking for. –  bh5k Nov 28 '12 at 16:51
add comment

2 Answers

Actually, Alex's solution will run every minute, every 2 hours between 8 am and 3pm, the right solution is:

0 8-17/2 * * * /path/command

Or even:

0 8,10,12,14,16 * * * /path/command

Which of course looks less nice, but still does what requested...

share|improve this answer
add comment
* 8-17/2 * * * your_command.sh
share|improve this answer
add comment

Your Answer

 
discard

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.