Crontab never running while in /etc/cron.d

Files in /etc/cron.d need to also list the user that the job is to be run under.

i.e.

0,15,30,45 * * * * root /backup.sh >/dev/null 2>&1

You should also ensure the permissions and owner:group are set correctly (-rw-r--r-- and owned by root:root)


Another thing I've observed is that the file in /etc/cron.d cannot have an extension. In my particular case, I had a symbolic link:

# my-job.crontab
* * * * * root echo "my job is running!" >> /tmp/my-job.log

$: ln -sf /home/me/my-job.crontab /etc/cron.d/
# This did not work -> job would not run

$: ln -sf /home/me/my-job.crontab /etc/cron.d/my-job
# This did work -> job ran fine

File name restriction are documented at run-part man page: http://manpages.ubuntu.com/manpages/xenial/man8/run-parts.8.html, one can pass an --regex option to override the file format.

The default cron behavior however stayed without extensions, see comments under: https://bugs.launchpad.net/ubuntu/+source/debianutils/+bug/38022


I think you probably just missing a necessary blank line from the end of your cron file. I had the same issue, but after checking everything listed here (user permissions, filename, cron version etc.), I realized that I did not have line break after the last entry in my /etc/cron.d/own_cron and that causes the entire file being ignored.

Tags:

Cron

Debian