Why doesn't my cron.d per minute job run?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Drifting Through My Dreams
--
Chapters
00:00 Why Doesn'T My Cron.D Per Minute Job Run?
00:51 Answer 1 Score 4
01:33 Accepted Answer Score 52
02:03 Thank you
--
Full question
https://superuser.com/questions/664454/w...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #cron
#avk47
ACCEPTED ANSWER
Score 52
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).
ANSWER 2
Score 4
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