Why doesn't my cron.d per minute job run?

When adding a cron configuration in /etc/cron.d/ or in /etc/crontab you have to add the username in which context the command should run, in your example

* * * * * root /bin/touch /home/me/ding_dong

And just a hint from me: you don't have to start running ls -ltr again and again, just use watch -n 5 "ls -ltr" and it will run the command every 5 seconds (or any other value by replacing 5 with what you want).


To create a new cron job, you should run crontab -e as the user you want running the job. Then add the relevant line in the editor window that appears:

* * * * * /bin/touch /home/me/ding_dong

The way you are doing it requires a different format and is really not a good idea anyway. Crontabs in /etc/cron.d have a slightly different format, they require a user name to be run under. For example:

* * * * * USERNAME /bin/touch /home/me/ding_dong

A good trick (as suggested by @VogonPoetLaureate) is to capture the standard error of your cron jobs which can help debug them. For example:

* * * * * /bin/touch /home/me/ding_dong 2>/tmp/error

A possible mistake here is how a single line file is created. From Ubuntu Documentation:

...line has five time-and-date fields, followed by a command, followed by a newline character.

For example, this way of the creation doesn't work:

printf "* * * * * /bin/touch /home/me/ding_dong" > /etc/cron.d/ding_dong

Tags:

Linux

Cron