Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
512 views
in Technique[技术] by (71.8m points)

unix - Cron Job is not working to automatically run a script every 12 hours

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...