Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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

2 Answers 2

up vote 12 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

 
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.