Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to set a cronjob entry that runs a script every 30 minutes from 9:00 to 18:00 but I do not want it to run at 18:30. The script should run for the first time at 9:00 and for the last time at 18:00. Is this possible?

share|improve this question
The question was answered here. – krmbzds Jun 28 '12 at 16:38
up vote 13 down vote accepted
0,30 9-18 * * * /path_to_script

However, the above will run at 18:30. So, you're best bet is to have a separate job to handle 18:00. So:

0,30 9-17 * * * /path_to_script
0 18 * * * /path_to_script

Also, Cron job generators are awesome.

share|improve this answer
This is a great answer! – dotancohen Jun 28 '12 at 16:48
I was wishing to accomplish this in a single line but I later learned that it was not possible only using cron. Thanks for your answer. – krmbzds Jun 28 '12 at 16:57

Or do an extra test before firing the script. In the example below I test if current is less than 1815.

 0,30 9-18 * * * [ $(date +\%H\%M) -le 1815 ] && /path_to_script
share|improve this answer

Your Answer


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.