Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I have a script that creates a file in cron.d and puts some jobs in it. Cron seems to not execute these jobs at all, since the program it runs is set to log all executions. The file inside cron.d looks something like this:

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
*/1 * * * * root /usr/bin/python /home/myname/some_script.py --switch1
2 21 * * 4 root /usr/bin/python /home/myname/some_script.py --switch2 --switch3

Neither of these jobs is executed and I can't find anything in grep CRON /var/log/syslog. The scripts work fine when executed normally. Any ideas?

EDIT: Adding the line */1 * * * * root echo "something" >> /tmp/something works fine.

Note: Though AskUbuntu won't show it, the file does have a trailing newline.

share|improve this question
add comment

1 Answer

Turns out, my script was creating the file in cron.d with the wrong permissions. This was causing cron to ignore the script.

chmod 600 /etc/cron.d/myfile fixed the problem.

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.