{"id":20794,"date":"2020-01-31T13:08:47","date_gmt":"2020-01-31T05:08:47","guid":{"rendered":"http:\/\/4563.org\/?p=20794"},"modified":"2020-01-31T13:08:47","modified_gmt":"2020-01-31T05:08:47","slug":"crontab-%e6%89%a7%e8%a1%8c%e6%97%b6%e9%97%b4%e9%97%ae%e9%a2%98%e3%80%82","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=20794","title":{"rendered":"crontab \u6267\u884c\u65f6\u95f4\u95ee\u9898\u3002"},"content":{"rendered":"\n<p>  \t\t\t\t\t<strong>loveqianool<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:04:38\t<\/p>\n<h3>crontab \u6267\u884c\u65f6\u95f4\u95ee\u9898\u3002<\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 loveqianool \u4e8e 2020-1-12 13:59 \u7f16\u8f91 <\/p>\n<p> https:\/\/i.loli.net\/2020\/01\/12\/bQDci6PEkFySgqC.png<\/p>\n<p>  \u6211\u4e0b\u4e86\u4e00\u4e2a\u5927\u4f6c\u7684\u7b7e\u5230\u811a\u672c\u6bcf\u5929\u6267\u884c\uff0c<br \/>  crontab 0 4 * * * \u4e0d\u5e94\u8be5\u662f\u51cc\u6668\u56db\u70b9\u5417\uff1f \u4e3a\u4ec0\u4e48\u6211\u8fd9\u8fb9\u90fd\u662f\u6bcf\u5929\u4e0b\u534817:00:01 \u6267\u884c\u3002<\/p>\n<p>  ==============<br \/>  \u6211 Python \u83b7\u53d6\u65f6\u95f4\u662f\u8fd9\u6837\u83b7\u53d6\u7684<br \/>  &gt;&gt;&gt; from datetime import datetime<br \/>  &gt;&gt;&gt; <br \/>  &gt;&gt;&gt; now = datetime.now()<br \/>  &gt;&gt;&gt; time = now.strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)<br \/>  &gt;&gt;&gt; print(time)<br \/>  2020-01-12 13:14:17<\/p>\n<p>  \u662f\u672c\u5730\u65f6\u95f4\u5440\uff0c\u7406\u8bba\u4e0a\u4e0d\u7ba1\u4ec0\u4e48\u65f6\u533a\u90fd\u662f\u51cc\u6668\u56db\u70b9\u5427\uff1f<\/p>\n<p>  =<br \/>  https:\/\/stackoverflow.com\/questions\/28195736\/which-timezone-does-cron-use-on-ubuntu-14-04\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>\u674e\u5929\u9a84<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:05:16\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u65f6\u533a\uff1f\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>cherbim<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:07:34\t<\/p>\n<h3><\/h3>\n<p>  \t\t \u672c\u5e16\u6700\u540e\u7531 cherbim \u4e8e 2020-1-12 13:10 \u7f16\u8f91 <\/p>\n<p> \u8f93\u5165date\u770b\u4e0bvps\u65f6\u533a\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>loveqianool<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:08:31\t<\/p>\n<h3><\/h3>\n<p>  \t\t\u674e\u5929\u9a84 \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:05<br \/>  \u65f6\u533a\uff1f<\/p>\n<p>  \u65f6\u533a\u662f HKT \u5440\uff0c\u518d\u8bf4\u6211\u811a\u672c\u7528\u7684\u662f\u672c\u5730\u65f6\u95f4\uff0c\u5c31\u662f\u65f6\u533a\u4e0d\u5bf9\u4e5f\u5e94\u8be5\u662f\u5bf9\u5e94\u65f6\u533a\u7684 \u51cc\u6668\u56db\u70b9 \u6267\u884c\u5440\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>loveqianool<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:10:46\t<\/p>\n<h3><\/h3>\n<p>  \t\tcherbim \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:07<br \/>  \u8f93\u5165time\u770b\u4e0bvps\u65f6\u533a<\/p>\n<p> \u5927\u4f6c\u4f60\u4eec\u770b\u4e0d\u5230\u56fe\u5417\uff1f \u65f6\u533a\u662f\u9999\u6e2f +0800\u3002\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>coobar\u0081<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:12:23\t<\/p>\n<h3><\/h3>\n<p>  \t\tcp \/usr\/share\/zoneinfo\/Asia\/Shanghai \/etc\/localtime&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br \/>  hwclock -w&nbsp; &nbsp; &nbsp; &nbsp; <\/p>\n<p>  \u6539\u4e3a\u4e2d\u56fd\u65f6\u533a\u5c31\u53ef\u4ee5\u4e86\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>plumn<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:16:57\t<\/p>\n<h3><\/h3>\n<p>  \t\ttimedatectl set-timezone Asia\/Shanghai<br \/>  service crond restart<br \/>  service rsyslog restart<br \/>  \u518d\u770b\u770b\u662f\u5426\u65e5\u5fd7\u66f4\u65b0\u4e3a\u51c6\u786e\u65f6\u533a\uff1a<br \/>  tail -f \/var\/log\/cron  \t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>loveqianool<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:24:40\t<\/p>\n<h3><\/h3>\n<p>  \t\tplumn \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:16<br \/>  \u518d\u770b\u770b\u662f\u5426\u65e5\u5fd7\u66f4\u65b0\u4e3a\u51c6\u786e\u65f6\u533a\uff1a<\/p>\n<p> \u279c~ sudo systemctl status cron.service<\/p>\n<p>  \u25cf cron.service &#8211; Regular background program processing daemon<br \/>  &nbsp; &nbsp;Loaded: loaded (\/lib\/systemd\/system\/cron.service; enabled; vendor preset: enabled)<br \/>  &nbsp; &nbsp;Active: active (running) since Sun 2019-12-22 01:40:09 HKT; 3 weeks 0 days ago<\/p>\n<p>  Debian 10 \uff0c\u770b\u8d77\u6765\u662f\u8fd0\u884c\u5728 HTK \u65f6\u533a\u3002<br \/>  \u279c~ sudo tail -f \/var\/log\/cron&nbsp; &nbsp;&nbsp; &nbsp; <br \/>  tail: cannot open &#8216;\/var\/log\/cron&#8217; for reading: No such file or directory\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>plumn<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:28:30\t<\/p>\n<h3><\/h3>\n<p>  \t\tloveqianool \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:24<br \/>  Debian 10 \uff0c\u770b\u8d77\u6765\u662f\u8fd0\u884c\u5728 HTK \u65f6\u533a\u3002<\/p>\n<p> debian\u6ca1\u7528\u8fc7\uff0c\u4f60\u767e\u5ea6\u641c\u641c\u770b\uff0c\u65f6\u533a\u80af\u5b9a\u662f\u4e0d\u5bf9\u7684\uff0c\u4e0d\u662f\u54ea\u91cc\u673a\u5668\u5c31\u662f\u54ea\u91cc\u65f6\u533a\u7684\uff0c\u4f60\u5f97\u81ea\u5df1\u8bbe\u7f6e\t\t\t\t<\/p>\n<p>  \t\t\t\t\t<strong>loveqianool<\/strong>  \t\t\t\t\u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:30:02\t<\/p>\n<h3><\/h3>\n<p>  \t\tplumn \u5927\u4f6c\u6709\u8bdd\u8bf4 : 2020-1-12 13:28<br \/>  debian\u6ca1\u7528\u8fc7\uff0c\u4f60\u767e\u5ea6\u641c\u641c\u770b\uff0c\u65f6\u533a\u80af\u5b9a\u662f\u4e0d\u5bf9\u7684\uff0c\u4e0d\u662f\u54ea\u91cc\u673a\u5668\u5c31\u662f\u54ea\u91cc\u65f6\u533a\u7684\uff0c\u4f60\u5f97\u81ea\u5df1\u8bbe\u7f6e &#8230;<\/p>\n<p>  \u279c~ timedatectl<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Local time: Sun 2020-01-12 13:29:27 HKT<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;Universal time: Sun 2020-01-12 05:29:27 UTC<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;RTC time: Sun 2020-01-12 05:29:28<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; Time zone: Asia\/Hong_Kong (HKT, +0800)<br \/>  System clock synchronized: yes<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;NTP service: active<br \/>  &nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; RTC in local TZ: no<br \/>  \u279c~ date -R<br \/>  Sun, 12 Jan 2020 13:29:32 +0800<\/p>\n<p>  \u6211\u8bbe\u7f6e\u4e86\u65f6\u533a\u5440\u5927\u4f6c\uff0c\u6211\u8bbe\u7f6e\u5b8c\u8fd8\u91cd\u542f\u4e86\uff0c \u6211\u672c\u5730\u65f6\u95f4\u662f\u5bf9\u7684\u5440\u3002\t\t\t  <\/p>\n","protected":false},"excerpt":{"rendered":"<p>loveqianool \u5927\u4f6c\u6709\u8bdd\u8bf4&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/20794"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20794"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/20794\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20794"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}