Server Fault is a question and answer site for system and network administrators. 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

We have a cron job under a specific user's crontab which should be running only on working week days. Job was running all days before we changed it.

After we changed in the following line the days statement from '*' to '1-5', is still running all days and the weekend that is not supposed to.

00 21 * * 1-5 /usr/local/bin/ >> /var/log/userdirectory/test_script.log 2>&1

Any ideas why?

share|improve this question
00 21 * * 1-5 instead of this can you try 0 21 * * 1-5 and check if this works or not. – Abhishek Anand Amralkar Sep 30 '13 at 13:05
The '00' versus '0' in the first column has nothing to do with the problem. How did you edit the crontab file, via vi or via crontab -e or some other way? – John Sep 30 '13 at 13:18
We had changed it in /var/spool/cron/crontabs/usercronjobs and then with crontab -e. – fotag Oct 1 '13 at 11:14
Fixed with deletion and recreation of the specific line via crontab -e. Maybe this line inserted there without crontab -e and hasn't installed correctly. Anyway, thanks for your ideas! – fotag Dec 11 '13 at 10:59

Well, the most likely case is that something went wrong when you were updating crontab. If you can't track down the specific issue, there's an easy workaround: in, add a couple of lines to quit if it's not one of the correct days for running the script. Something like:

#quit if we're doing this on the wrong day of the week
if date | grep Sun &> /dev/null
exit 0
if date | grep Sat &> /dev/null
exit 0

(yes, I know there's better ways to do those statements; this is just a way to do it that is really easy to understand and see what it's doing)

share|improve this answer
Thanks for your answer! I think will try sth like this until we find out what is going there – fotag Oct 3 '13 at 12:52

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.