{"id":2703,"date":"2016-07-15T10:02:42","date_gmt":"2016-07-15T02:02:42","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=2703"},"modified":"2016-07-15T10:02:42","modified_gmt":"2016-07-15T02:02:42","slug":"%e4%bb%8e%e4%b8%80%e6%ac%a1linux%e8%ae%a1%e5%88%92%e4%bb%bb%e5%8a%a1%e4%b8%8d%e6%89%a7%e8%a1%8c%e7%9a%84%e9%97%ae%e9%a2%98%e6%8e%92%e6%9f%a5%e8%bf%87%e7%a8%8b%e8%af%b4%e8%b5%b7","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/2703.html","title":{"rendered":"\u4ece\u4e00\u6b21Linux\u8ba1\u5212\u4efb\u52a1\u4e0d\u6267\u884c\u7684\u95ee\u9898\u6392\u67e5\u8fc7\u7a0b\u8bf4\u8d77"},"content":{"rendered":"<p>=Start=<\/p>\n<h5>\u7f18\u7531\uff1a<\/h5>\n<p>\u5728VPS\u4e0a\u6709\u4e00\u4e2a\u626b\u63cf\u7684\u5b9a\u65f6\u4efb\u52a1\u6ca1\u6709\u6b63\u5e38\u8fd0\u884c\uff0c\u6240\u4ee5\u9700\u8981\u5b9a\u4f4d\u4e00\u4e0b\u95ee\u9898\u5230\u5e95\u51fa\u5728\u54ea\u4e86\uff1acron\u6ca1\u6709\u6b63\u5e38\u8fd0\u884c\uff1f\u8fd8\u662f\u56e0\u4e3a\u811a\u672c\u8fd0\u884c\u65f6\u957f\u592a\u957f\u4e86\u5bfc\u81f4\u6267\u884c\u4e0d\u6210\u529f\uff1f\u4ea6\u6216\u662f\u811a\u672c\u4e2d\u67d0\u4e2a\u547d\u4ee4\u592a\u957f\u5bfc\u81f4\u6267\u884c\u5931\u8d25\uff1f<\/p>\n<h5>\u8fc7\u7a0b\uff1a<\/h5>\n<h6>\u67e5\u770b\u6587\u6863\uff08RTFM\uff09<\/h6>\n<ul>\n<li>\/etc\/crontab<\/li>\n<li>\/var\/spool\/cron\/*<\/li>\n<li>\/etc\/cron.{hourly,daily,weekly,monthly}\/<\/li>\n<li>\/etc\/anacrontab<\/li>\n<\/ul>\n<h6>\u68c0\u67e5\u65e5\u5fd7\uff08RTFL\uff09<\/h6>\n<ul>\n<li><span style=\"color: #ff0000;\"><strong>\/var\/log\/cron<\/strong><\/span>*<\/li>\n<li>\/var\/spool\/mail\/*<\/li>\n<\/ul>\n<h6>\u68c0\u67e5\u811a\u672c<\/h6>\n<p><strong>1.\u76f4\u63a5\u6267\u884c<\/strong><\/p>\n<ul>\n<li>\u5728\u547d\u4ee4\u884c\u4e0a\u76f4\u63a5\u6267\u884c\uff08Tips\uff1a\u9700\u8981<span style=\"color: #ff0000;\"><strong>\u5728\u591a\u4e2a\u4e0d\u540c\u76ee\u5f55\u4e2d\u8fdb\u884c\u6d4b\u8bd5<\/strong><\/span>\uff0c\u9632\u6b62\u56e0\u4e3a\u8def\u5f84\u95ee\u9898\u5bfc\u81f4\u7684\u9519\u8bef\uff09\uff1b<\/li>\n<li>\u901a\u8fc7\u53e6\u5916\u4e00\u4e2a\u811a\u672c\u8c03\u7528\u6267\u884c\uff08Tips\uff1a<span style=\"color: #ff0000;\">\u6709\u4e9b\u7a0b\u5e8f\u5728\u975e\u7ec8\u7aef\u60c5\u51b5\u4e0b\u65e0\u6cd5\u6b63\u5e38\u6267\u884c<\/span>\uff09<\/li>\n<\/ul>\n<p><strong>2.\u67e5\u770bcron\u4e2d\u7684\u73af\u5883\u53d8\u91cf<\/strong><\/p>\n<ul>\n<li><span style=\"color: #0000ff;\"><strong>\u5728\u81ea\u5df1\u5199\u7684\u811a\u672c\u4e2d\u624b\u52a8\u8bbe\u5b9a\u73af\u5883\u53d8\u91cfPATH<\/strong><\/span>\uff08\u4e5f\u53ef\u4ee5\u901a\u8fc7source\u547d\u4ee4\u8f7d\u5165\u5176\u5b83\u811a\u672c\u7528\u6765\u8bbe\u7f6e\u73af\u5883\u53d8\u91cf\uff09\uff1b<\/li>\n<li>\u5148\u5206\u6790\u4e00\u4e0b\u73b0\u6709cron\u4e2d\u7684\u73af\u5883\u53d8\u91cf\u300c`* * * * * env &gt; \/tmp\/env.output`\u300d\uff1b<\/li>\n<\/ul>\n<p><strong>3.\u67e5\u770b\u90ae\u4ef6<\/strong><\/p>\n<p>\u6b63\u5e38\u60c5\u51b5\u4e0b\uff0ccrontab\u6267\u884c\u5931\u8d25\uff0c\u5728\u6ca1\u6709\u5c4f\u853d\u9519\u8bef\u7684\u60c5\u51b5\u4e0b\u4f1a\u4ea7\u751f\u4e00\u5c01\u7cfb\u7edf\u90ae\u4ef6\uff0c\u4f4d\u4e8e \/var\/spool\/mail\/root \uff0c\u53ef\u4ee5\u901a\u8fc7\u67e5\u770b\u90ae\u4ef6\u5185\u5bb9\u6765\u5206\u6790\u9519\u8bef\u539f\u56e0\u3002<\/p>\n<h5>\u539f\u56e0\u603b\u7ed3\uff1a<\/h5>\n<ol>\n<li>crontab\u670d\u52a1\u672a\u6b63\u5e38\u8fd0\u884c\uff08<strong><span style=\"color: #ff0000;\">\u67e5\u770b \/var\/log\/cron \u6216 \/var\/log\/messages \u65e5\u5fd7<\/span><\/strong>\uff09\uff1b<\/li>\n<li>\u811a\u672c\u6743\u9650\u95ee\u9898\uff08`ls -l`\u67e5\u770b\u811a\u672c\u7684<span style=\"color: #0000ff;\">\u5c5e\u4e3b\u4ee5\u53ca\u53ef\u6267\u884c\u4f4d<\/span>\u662f\u5426\u5df2\u8bbe\u7f6e\uff09\uff1b<\/li>\n<li>\u73af\u5883\u53d8\u91cf\u95ee\u9898\uff08<span style=\"color: #ff0000;\"><strong>\u624b\u52a8\u8bbe\u7f6ePATH<\/strong><\/span>\uff09\uff1b<\/li>\n<li>\u8def\u5f84\u95ee\u9898\uff08<span style=\"color: #ff0000;\"><strong>\u6240\u6709\u9700\u8981\u7528\u5230\u8def\u5f84\u7684\u5730\u65b9\u90fd\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84<\/strong><\/span>\uff09\uff1b<\/li>\n<\/ol>\n<p>\u53e6\uff0c\u5728\u6700\u521d\u4ee5\u4e3a\u662fcron\u672c\u8eab\u4e0d\u652f\u6301\u300c\u957f\u65f6\u95f4\u4efb\u52a1\u300d\u6216\u300c\u547d\u4ee4\u8fc7\u957f\u300d\u5bfc\u81f4\u5b9a\u65f6\u4efb\u52a1\u65e0\u6cd5\u6b63\u5e38\u6267\u884c\uff0c\u4f46\u662f\u540e\u6765\u901a\u8fc7\u9605\u8bfbcrontab\u6e90\u7801\u53d1\u73b0\u5e76\u6ca1\u6709\u8fd9\u4e9b\u9650\u5236\uff0c\u6240\u4ee5\u4ee5\u540e\u5982\u679c\u78b0\u5230cron\u4efb\u52a1\u6709\u95ee\u9898\u4e86\uff0c\u8001\u8001\u5b9e\u5b9e\u6309\u7167\u4e0a\u9762\u7684\u51e0\u4e2a\u539f\u56e0\u8fdb\u884c\u5206\u6790\uff0c\u80af\u5b9a\u53ef\u4ee5\u89e3\u51b3\u95ee\u9898\u7684\u3002<\/p>\n<h5>\u53c2\u8003\u94fe\u63a5\uff1a<\/h5>\n<ul>\n<li><a href=\"http:\/\/zhangge.net\/5093.html\">\u5206\u4eab\u4e00\u6b21Linux\u4efb\u52a1\u8ba1\u5212crontab\u4e0d\u6267\u884c\u7684\u95ee\u9898\u6392\u67e5\u8fc7\u7a0b<\/a><\/li>\n<li><a href=\"http:\/\/serverfault.com\/questions\/449651\/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it\" target=\"_blank\">http:\/\/serverfault.com\/questions\/449651\/why-is-my-crontab-not-working-and-how-can-i-troubleshoot-it<\/a><\/li>\n<li><a href=\"http:\/\/askubuntu.com\/questions\/23009\/reasons-why-crontab-does-not-work\" target=\"_blank\">http:\/\/askubuntu.com\/questions\/23009\/reasons-why-crontab-does-not-work<\/a><\/li>\n<li><a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-schedule-routine-tasks-with-cron-and-anacron-on-a-vps\" target=\"_blank\">https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-schedule-routine-tasks-with-cron-and-anacron-on-a-vps<\/a><\/li>\n<li><a href=\"http:\/\/www.cyberciti.biz\/faq\/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses\/\" target=\"_blank\">http:\/\/www.cyberciti.biz\/faq\/how-do-i-add-jobs-to-cron-under-linux-or-unix-oses\/<\/a><\/li>\n<\/ul>\n<p>=END=<\/p>\n","protected":false},"excerpt":{"rendered":"<p>=Start= \u7f18\u7531\uff1a \u5728VPS\u4e0a\u6709\u4e00\u4e2a\u626b\u63cf\u7684\u5b9a\u65f6\u4efb\u52a1\u6ca1\u6709\u6b63\u5e38\u8fd0\u884c\uff0c\u6240\u4ee5\u9700\u8981\u5b9a\u4f4d\u4e00\u4e0b\u95ee\u9898\u5230\u5e95\u51fa\u5728\u54ea\u4e86\uff1acron [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23,11,7],"tags":[63,575,30],"class_list":["post-2703","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","category-linux","category-programing","tag-crontab","tag-debug","tag-linux"],"views":7804,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2703","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=2703"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/2703\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=2703"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=2703"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=2703"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}