crontab 執行時間與系統時間不一致

來源:本站原創 Linux 超過2,598 views圍觀 0條評論

crontab 執行時間與系統時間不一致。

原因:之前改過時區:

解決 只要改過時間都需要重啟crontab 服務,別想著只重啟服務器。

 

[[email protected] download]# date
Wed Dec 27 09:24:05 CST 2017
[[email protected] download]# date
Wed Dec 27 09:24:11 CST 2017
[[email protected] download]# tail -f /var/log/cron
Dec 26 20:15:01
mysql01 CROND[3845]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:16:01 mysql01 CROND[3952]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:17:01 mysql01 CROND[4058]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:18:01 mysql01 CROND[4164]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)

重啟測試

[[email protected] download]# systemctl status crond
● crond.service – Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-12-27 09:28:31 CST; 12s ago
Main PID: 5361 (crond)
   CGroup: /system.slice/crond.service
           └─5361 /usr/sbin/crond -n

Dec 27 09:28:31 mysql01 systemd[1]: Started Command Scheduler.
Dec 27 09:28:31 mysql01 systemd[1]: Starting Command Scheduler…
Dec 27 09:28:31 mysql01 crond[5361]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 93% if used.)
Dec 27 09:28:31 mysql01 crond[5361]: (CRON) INFO (running with inotify support)
Dec 27 09:28:31 mysql01 crond[5361]: (CRON) INFO (@reboot jobs will be run at computer’s startup.)
[[email protected] download]#
[[email protected] download]#
[[email protected] download]# !tail
tail -f /var/log/cron
Dec 26 20:23:01 mysql01 CROND[4695]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:24:01 mysql01 CROND[4805]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:25:01 mysql01 CROND[4913]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:26:01 mysql01 CROND[5021]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:27:01 mysql01 CROND[5126]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:28:01 mysql01 CROND[5244]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:28:31 mysql01 crond[2416]: (CRON) INFO (Shutting down)
Dec 26 20:28:31 mysql01 crond[5361]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 93% if used.)
Dec 26 20:28:31 mysql01 crond[5361]: (CRON) INFO (running with inotify support)
Dec 26 20:28:31 mysql01 crond[5361]: (CRON) INFO (@reboot jobs will be run at computer’s startup.)
Dec 26 20:29:01 mysql01 CROND[5367]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)=

 

然鵝,并沒有如你所想

Dec 26 20:28:31 mysql01 crond[5361]: (CRON) INFO (@reboot jobs will be run at computer’s startup.)
Dec 26 20:29:01 mysql01 CROND[5367]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:30:01 mysql01 CROND[5472]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:31:01 mysql01 CROND[5580]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)

 

———-真實的解決方式。——————–

[[email protected] download]# systemctl start crond————–1

[[email protected] ~]# systemctl restart rsyslog—————–2
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# systemctl status rsyslog
● rsyslog.service – System Logging Service
   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2017-12-27 09:37:58 CST; 5s ago
Main PID: 6370 (rsyslogd)
   CGroup: /system.slice/rsyslog.service
           └─6370 /usr/sbin/rsyslogd -n

Dec 27 09:37:58 mysql01 systemd[1]: Starting System Logging Service…
Dec 27 09:37:58 mysql01 systemd[1]: Started System Logging Service.
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]#
[[email protected] ~]# tail -f /var/log/cron
Dec 26 20:32:21 mysql01 crond[5361]: (CRON) INFO (Shutting down)
Dec 26 20:32:29 mysql01 crond[5803]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 30% if used.)
Dec 26 20:32:29 mysql01 crond[5803]: (CRON) INFO (running with inotify support)
Dec 26 20:32:29 mysql01 crond[5803]: (CRON) INFO (@reboot jobs will be run at computer’s startup.)
Dec 26 20:33:01 mysql01 CROND[5807]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:34:01 mysql01 CROND[5938]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:35:01 mysql01 CROND[6045]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:36:01 mysql01 CROND[6152]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 26 20:37:01 mysql01 CROND[6259]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)
Dec 27 09:38:01 mysql01 CROND[6376]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)

————解決——————————–
Dec 27 09:39:01 mysql01 CROND[6484]: (root) CMD (/bin/bash /opt/download/rehttp.sh http://192.168.142.138/nginx-logo.png 100)

——————–提醒————————————-

只要改時間,都建議將現運行的服務重啟一遍

文章出自:CCIE那點事 http://www.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文鏈接:http://www.qdxgqk.live/?p=3651轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
  • 相關文章
  • 為您推薦
  • 各種觀點
?
暫時還木有人評論,坐等沙發!
發表評論

您必須 [ 登錄 ] 才能發表留言!

?
?
萌宠夺宝游戏