I have made a cron job using crontab -e
and it is supposed to exec after every 12 hours. For some reason, it is not working.
I want to execute a script that monitors a particular subdomain and the script works when I run it separately so I know there are no problems with the script.
Here is the output of crontab -e
:
0 12 * * */1 /root/tools/Monitor/monitor.sh
I checked the error log using grep CRON /var/log/syslog
and here is the latest error that I see:
Jan 23 19:39:01 savxiety CRON[232193]: (root) CMD ( [ -x /usr/lib/php/sessionclean ] && if [ ! -d /run/systemd/system ]; then /usr/lib/php/sessionclean; fi)
I have tried a lot of things, asked from some friends, checked out another question on SO but couldn't get this one working.
Thanks :)
OK, if you add a line like date > /tmp/last-started.txt as first statement to /root/tools/Monitor/monitor.sh, do you get a confirmation that the jobs was started?
- Yes I do get a confirmation that the script was run. This happens via a notification to my discord because of the
| notify
in the script.
I just saw that: What is */1 in crontab expected to do?
So */1 does not make any sense and you say your script is started. So what's the problem? – U. Windl
- The problem is that my script is not starting every 12th hour and I think that is happening because of a problem in my cron configuration. To verify that it ran, I get a ping on my discord server that the script ran successfully, but after 12 hours, I don't get pinged for some reason which means that the script did not run after the 12 hour period.
question from:
https://stackoverflow.com/questions/65863743/cron-job-is-not-working-to-automatically-run-a-script-every-12-hours 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…