{"id":353,"date":"2012-03-12T16:51:09","date_gmt":"2012-03-12T08:51:09","guid":{"rendered":"http:\/\/www.kiccleaf.com\/?p=353"},"modified":"2012-03-12T16:59:39","modified_gmt":"2012-03-12T08:59:39","slug":"linux-centos%e7%b3%bb%e7%bb%9fcrontab%e8%bf%90%e8%a1%8c%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1","status":"publish","type":"post","link":"http:\/\/www.kiccleaf.com\/?p=353","title":{"rendered":"Linux CentOS\u7cfb\u7edfcrontab\u8fd0\u884c\u5b9a\u65f6\u4efb\u52a1"},"content":{"rendered":"<p>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7cfb\u7edf\u9ed8\u8ba4\u90fd\u5df2\u7ecf\u5b89\u88c5\u597d\uff0c\u5982\u679c\u53d1\u73b0\u4e0d\u80fd\u4f7f\u7528\u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5<br \/>\nyum install crontabs<\/p>\n<p>\u8bf4\u660e\uff1a<br \/>\n\/sbin\/service crond start \/\/\u542f\u52a8\u670d\u52a1<br \/>\n\/sbin\/service crond stop \/\/\u5173\u95ed\u670d\u52a1<br \/>\n\/sbin\/service crond restart \/\/\u91cd\u542f\u670d\u52a1<br \/>\n\/sbin\/service crond reload \/\/\u91cd\u65b0\u8f7d\u5165\u914d\u7f6e<\/p>\n<p>1\uff0ccrontab\u547d\u4ee4<\/p>\n<p>\u529f\u80fd\u8bf4\u660e\uff1a\u8bbe\u7f6e\u8ba1\u65f6\u5668\u3002<\/p>\n<p>\u8bed\u3000\u3000\u6cd5\uff1acrontab [-u <\u7528\u6237\u540d\u79f0>][\u914d\u7f6e\u6587\u4ef6] \u6216 crontab [-u <\u7528\u6237\u540d\u79f0>][-elr]<\/p>\n<p>\u8865\u5145\u8bf4\u660e\uff1acron\u662f\u4e00\u4e2a\u5e38\u9a7b\u670d\u52a1\uff0c\u5b83\u63d0\u4f9b\u8ba1\u65f6\u5668\u7684\u529f\u80fd\uff0c\u8ba9\u7528\u6237\u5728\u7279\u5b9a\u7684\u65f6\u95f4\u5f97\u4ee5\u6267\u884c\u9884\u8bbe\u7684\u6307\u4ee4\u6216\u7a0b\u5e8f\u3002\u53ea\u8981\u7528\u6237\u4f1a\u7f16\u8f91\u8ba1\u65f6\u5668\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u5c31\u53ef\u4ee5\u4f7f \u7528\u8ba1\u65f6\u5668\u7684\u529f\u80fd\u3002\u5176\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\u5982\u4e0b\uff1a<br \/>\nMinute Hour Day Month DayOFWeek Command<\/p>\n<p>\u53c2\u3000\u3000\u6570\uff1a<br \/>\n-e \u3000\u7f16\u8f91\u8be5\u7528\u6237\u7684\u8ba1\u65f6\u5668\u8bbe\u7f6e\u3002<br \/>\n-l \u3000\u5217\u51fa\u8be5\u7528\u6237\u7684\u8ba1\u65f6\u5668\u8bbe\u7f6e\u3002<br \/>\n-r \u3000\u5220\u9664\u8be5\u7528\u6237\u7684\u8ba1\u65f6\u5668\u8bbe\u7f6e\u3002<br \/>\n-u<\u7528\u6237\u540d\u79f0> \u3000\u6307\u5b9a\u8981\u8bbe\u5b9a\u8ba1\u65f6\u5668\u7684\u7528\u6237\u540d\u79f0\u3002<\/p>\n<p>2\uff0ccrontab \u683c\u5f0f<\/p>\n<p>\u57fa\u672c\u683c\u5f0f :<br \/>\n* *\u3000 *\u3000 *\u3000 *\u3000\u3000command<br \/>\n\u5206\u3000\u65f6\u3000\u65e5\u3000\u6708\u3000\u5468\u3000 \u547d\u4ee4<\/p>\n<p>\u7b2c1\u5217\u8868\u793a\u5206\u949f1\uff5e59 \u6bcf\u5206\u949f\u7528*\u6216\u8005 *\/1\u8868\u793a<br \/>\n\u7b2c2\u5217\u8868\u793a\u5c0f\u65f61\uff5e23\uff080\u8868\u793a0\u70b9\uff09<br \/>\n\u7b2c3\u5217\u8868\u793a\u65e5\u671f1\uff5e31<br \/>\n\u7b2c4\u5217 \u8868\u793a\u6708\u4efd1\uff5e12<br \/>\n\u7b2c5\u5217\u6807\u8bc6\u53f7\u661f\u671f0\uff5e6\uff080\u8868\u793a\u661f\u671f\u5929\uff09<br \/>\n\u7b2c6\u5217\u8981\u8fd0\u884c\u7684\u547d\u4ee4<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n# Use the hash sign to prefix a comment\r\n# +---------------- minute (0 - 59)\r\n# |  +------------- hour (0 - 23)\r\n# |  |  +---------- day of month (1 - 31)\r\n# |  |  |  +------- month (1 - 12)\r\n# |  |  |  |  +---- day of week (0 - 7) (Sunday=0 or 7)\r\n# |  |  |  |  |\r\n# *  *  *  *  *  command to be executed\r\n<\/pre>\n<p>\u914d\u5907\u81ea\u5df1\u7684\u4efb\u52a1<br \/>\ncrontab -e<\/p>\n<p>\u7136\u540e\u8f93\u5165\u81ea\u5df1\u6267\u884c\u7684Shell\u6587\u4ef6\u5730\u5740\u6216\u662f\u53ef\u6267\u884c\u6587\u4ef6\u7684\u5730\u5740<\/p>\n<p>\u67e5\u770b\u4efb\u52a1<br \/>\ncrontab -l<\/p>\n<p>\u7f51\u7edc\u4e0a\u627e\u7684\u548c\u81ea\u5df1\u5199\u7684\u4e00\u4e9bcrontab\u6587\u4ef6\u7684\u4f8b\u5b50\uff1a<br \/>\n\u6bcf\u592900\uff1a00\u505anginx\u65e5\u5fd7\u5207\u5272<br \/>\n00 00 * * * \/bin\/bash  \/data\/cut_nginx_log.sh<\/p>\n<p>59 23 * * * \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u665a\u768423:59\u91cd\u542f nginx\u3002<\/p>\n<p>45 4 1,10,22 * * \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u67081\u3001 10\u300122\u65e5\u76844 : 45\u91cd\u542fnginx\u3002<\/p>\n<p>10 1 * * 6,0 \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u5468\u516d\u3001\u5468\u65e5\u76841 : 10\u91cd\u542fnginx\u3002<\/p>\n<p>0,30 18-23 * * * \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u592918 : 00\u81f323 : 00\u4e4b\u95f4\u6bcf\u969430\u5206\u949f\u91cd\u542fnginx\u3002<\/p>\n<p>0 23 * * 6 \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u661f\u671f\u516d\u768411 : 00 pm\u91cd\u542fnginx\u3002<\/p>\n<p>* *\/1 * * * \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u4e00\u5c0f\u65f6\u91cd\u542fnginx<\/p>\n<p>* 23-7\/1 * * * \/etc\/init.d\/nginx restart<br \/>\n\u665a\u4e0a11\u70b9\u5230\u65e9\u4e0a7\u70b9\u4e4b\u95f4\uff0c\u6bcf \u9694\u4e00\u5c0f\u65f6\u91cd\u542fnginx<\/p>\n<p>0 11 4 * mon-wed \/etc\/init.d\/nginx restart<br \/>\n\u6bcf\u6708\u76844\u53f7\u4e0e\u6bcf\u5468\u4e00\u5230\u5468\u4e09 \u768411\u70b9\u91cd\u542fnginx<\/p>\n<p>0 4 1 jan * \/etc\/init.d\/nginx restart<br \/>\n\u4e00\u6708\u4e00\u53f7\u76844\u70b9\u91cd\u542fnginx<\/p>\n<p>*\/30 * * * * \/usr\/sbin\/ntpdate 210.72.145.20<br \/>\n\u6bcf\u534a\u5c0f\u65f6\u540c\u6b65\u4e00\u4e0b\u65f6\u95f4<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u7cfb\u7edf\u9ed8\u8ba4\u90fd\u5df2\u7ecf\u5b89\u88c5\u597d\uff0c\u5982\u679c\u53d1\u73b0\u4e0d\u80fd\u4f7f\u7528&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"http:\/\/www.kiccleaf.com\/?p=353\">Continue reading<span class=\"screen-reader-text\">Linux CentOS\u7cfb\u7edfcrontab\u8fd0\u884c\u5b9a\u65f6\u4efb\u52a1<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":5,"footnotes":""},"categories":[4],"tags":[75,13,76,77,78],"class_list":["post-353","post","type-post","status-publish","format-standard","hentry","category-linux-","tag-crontab","tag-linux","tag-76","tag-77","tag-78","entry"],"views":3082,"_links":{"self":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=353"}],"version-history":[{"count":0,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=\/wp\/v2\/posts\/353\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=353"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.kiccleaf.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}