{"id":208,"date":"2019-07-02T16:42:48","date_gmt":"2019-07-02T08:42:48","guid":{"rendered":"https:\/\/wp.dj47.top\/?p=208"},"modified":"2021-10-20T16:17:16","modified_gmt":"2021-10-20T08:17:16","slug":"linux%e4%b8%8b%e7%9a%84crontab%e5%ae%9a%e6%97%b6%e6%89%a7%e8%a1%8c%e4%bb%bb%e5%8a%a1%e5%91%bd%e4%bb%a4%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.djlog.cn\/?p=208","title":{"rendered":"Linux\u4e0b\u7684crontab\u5b9a\u65f6\u6267\u884c\u4efb\u52a1\u547d\u4ee4\u8be6\u89e3"},"content":{"rendered":"<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">\u5728LINUX\u4e2d\uff0c\u5468\u671f\u6267\u884c\u7684\u4efb\u52a1\u4e00\u822c\u7531cron\u8fd9\u4e2a\u5b88\u62a4\u8fdb\u7a0b\u6765\u5904\u7406[ps -ef|grep cron]\u3002cron\u8bfb\u53d6\u4e00\u4e2a\u6216\u591a\u4e2a\u914d\u7f6e\u6587\u4ef6\uff0c\u8fd9\u4e9b\u914d\u7f6e\u6587\u4ef6\u4e2d\u5305\u542b\u4e86\u547d\u4ee4\u884c\u53ca\u5176\u8c03\u7528\u65f6\u95f4\u3002<br style=\"box-sizing: border-box;\" \/>cron\u7684\u914d\u7f6e\u6587\u4ef6\u79f0\u4e3a\u201ccrontab\u201d\uff0c\u662f\u201ccron table\u201d\u7684\u7b80\u5199\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-weight: bold;\">\u4e00\u3001cron\u670d\u52a1<\/span><br style=\"box-sizing: border-box;\" \/>\u3000\u3000cron\u662f\u4e00\u4e2alinux\u4e0b \u7684\u5b9a\u65f6\u6267\u884c\u5de5\u5177\uff0c\u53ef\u4ee5\u5728\u65e0\u9700\u4eba\u5de5\u5e72\u9884\u7684\u60c5\u51b5\u4e0b\u8fd0\u884c\u4f5c\u4e1a\u3002<br style=\"box-sizing: border-box;\" \/>\u3000\u3000service cron start\u00a0 \u00a0 \/\/\u542f\u52a8\u670d\u52a1<br style=\"box-sizing: border-box;\" \/>\u3000\u3000service cron stop\u00a0 \u00a0\u00a0\u00a0\/\/\u5173\u95ed\u670d\u52a1<br style=\"box-sizing: border-box;\" \/>\u3000\u3000service cron restart\u00a0\u00a0\/\/\u91cd\u542f\u670d\u52a1<br style=\"box-sizing: border-box;\" \/>\u3000\u3000service cron reload\u00a0 \u00a0\/\/\u91cd\u65b0\u8f7d\u5165\u914d\u7f6e<br style=\"box-sizing: border-box;\" \/>\u3000\u3000service cron status\u00a0 \u00a0\/\/\u67e5\u770b\u670d\u52a1\u72b6\u6001<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">\u00a0\u00a0\u00a0\u00a0\u00a0<span style=\"box-sizing: border-box; color: #ff0000;\">crontab cron_text \u00a0 \u00a0\/\/\u521b\u5efa\u4efb\u52a1(\u7f16\u8f91\u597d\u547d\u4ee4\u540e;<span style=\"box-sizing: border-box;\">cron_text\u00a0\u662f\u547d\u4ee4\u6587\u4ef6<\/span>)<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-weight: bold;\">\u4e8c\u3001cron\u57283\u4e2a\u5730\u65b9\u67e5\u627e\u914d\u7f6e\u6587\u4ef6\uff1a<\/span><br style=\"box-sizing: border-box;\" \/>1\u3001\/var\/spool\/cron\/ \u8fd9\u4e2a\u76ee\u5f55\u4e0b\u5b58\u653e\u7684\u662f\u6bcf\u4e2a\u7528\u6237\u5305\u62ecroot\u7684crontab\u4efb\u52a1\uff0c\u6bcf\u4e2a\u4efb\u52a1\u4ee5\u521b\u5efa\u8005\u7684\u540d\u5b57\u547d\u540d\uff0c\u6bd4\u5982tom\u5efa\u7684crontab\u4efb\u52a1\u5bf9\u5e94\u7684\u6587\u4ef6\u5c31\u662f\/var\/spool\/cron\/tom\u3002\u4e00\u822c\u4e00\u4e2a\u7528\u6237\u6700\u591a\u53ea\u6709\u4e00\u4e2acrontab\u6587\u4ef6\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">2\u3001\u4fee\u6539\u914d\u7f6e<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">\u00a0 \u00a0\u00a0<span style=\"box-sizing: border-box; color: #ff0000;\">vim\u00a0<span style=\"box-sizing: border-box; font-family: 'Source Code Pro', 'DejaVu Sans Mono', 'Ubuntu Mono', 'Anonymous Pro', 'Droid Sans Mono', Menlo, Monaco, Consolas, Inconsolata, Courier, monospace, 'PingFang SC', 'Microsoft YaHei', sans-serif; font-size: 14px; font-variant-ligatures: common-ligatures; white-space: pre; background-color: #f6f8fa;\">\/etc\/rsyslog.d\/<\/span>50-default.conf<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">3\u3001\u65e5\u5fd7<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">\u00a0\u00a0\u00a0\u00a0<span style=\"box-sizing: border-box; color: #ff0000;\">vim\u00a0\/var\/log\/cron.log<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-weight: bold;\">\u4e09\u3001\/etc\/crontab \u8fd9\u4e2a\u6587\u4ef6\u8d1f\u8d23\u5b89\u6392\u7531\u7cfb\u7edf\u7ba1\u7406\u5458\u5236\u5b9a\u7684\u7ef4\u62a4\u7cfb\u7edf\u4ee5\u53ca\u5176\u4ed6\u4efb\u52a1\u7684crontab\u3002<\/span><\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">SHELL=\/bin\/bash<br style=\"box-sizing: border-box;\" \/>PATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin<br style=\"box-sizing: border-box;\" \/>MAILTO=root<br style=\"box-sizing: border-box;\" \/>HOME=\/<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"># For details see man 4 crontabs<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"># Example of job definition:<br style=\"box-sizing: border-box;\" \/># .&#8212;&#8212;&#8212;&#8212;&#8212;- minute (0 &#8211; 59)<br style=\"box-sizing: border-box;\" \/># | .&#8212;&#8212;&#8212;&#8212;- hour (0 &#8211; 23)<br style=\"box-sizing: border-box;\" \/># | | .&#8212;&#8212;&#8212;- day of month (1 &#8211; 31)<br style=\"box-sizing: border-box;\" \/># | | | .&#8212;&#8212;- month (1 &#8211; 12) OR jan,feb,mar,apr &#8230;<br style=\"box-sizing: border-box;\" \/># | | | | .&#8212;- day of week (0 &#8211; 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat<br style=\"box-sizing: border-box;\" \/># | | | | |<br style=\"box-sizing: border-box;\" \/># * * * * * user-name command to be executed<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='http:\/\/p.dj47.top\/data\/upload\/ueditor\/20190606\/5cf7e8626176c.png'><img class=\"lazyload lazyload-style-8\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" style=\"box-sizing: border-box; border: 0px; vertical-align: middle; max-width: 900px; height: auto;\" data-original=\"http:\/\/p.dj47.top\/data\/upload\/ueditor\/20190606\/5cf7e8626176c.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<ul class=\" list-paddingleft-2\" style=\"box-sizing: border-box; margin-top: 0px; margin-bottom: 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff; list-style-type: none;\">\n<li style=\"box-sizing: border-box;\">\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px;\"><span style=\"box-sizing: border-box;\">MAILTO=root\uff1a\u662f\u8bf4\uff0c\u5f53 \/etc\/crontab \u8fd9\u4e2a\u6863\u6848\u4e2d\u7684\u4f8b\u884c\u6027\u547d\u4ee4\u53d1\u751f\u9519\u8bef\u65f6\uff0c\u4f1a\u5c06\u9519\u8bef\u8baf\u606f\u6216\u8005\u662f\u5c4f\u5e55\u663e\u793a\u7684\u8baf\u606f\u4f20\u7ed9\u8c01\uff1f\u7531\u4e8e root \u5e76\u65e0\u6cd5\u518d\u7528\u6237\u7aef\u6536\u4fe1\uff0c\u56e0\u6b64\uff0c\u6211\u901a\u5e38\u90fd\u5c07\u8fd9\u4e2a e-mail \u6539\u6210\u81ea\u5df1\u7684\u8d26\u53f7\uff0c\u597d\u8ba9\u6211\u968f\u65f6\u4e86\u89e3\u7cfb\u7edf\u7684\u72b6\u6001\uff01<\/span><\/p>\n<\/li>\n<li style=\"box-sizing: border-box;\">\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px;\"><span style=\"box-sizing: border-box;\"><span style=\"box-sizing: border-box; font-weight: bold;\"><span style=\"box-sizing: border-box; font-family: \u7d30\u660e\u9ad4; color: #000000;\">01 * * * * root run-parts \/etc\/cron.hourly<\/span><\/span>\uff1a\u5728 #run-parts \u8fd9\u4e00\u884c\u4ee5\u540e\u7684\u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u53d1\u73b0\uff0c\u4e94\u4e2a\u6570\u5b57\u540e\u9762\u63a5\u7684\u662f root \uff0c\u8fd9\u4e00\u884c\u4ee3\u8868\u7684\u662f\u300e\u6267\u884c\u7684\u7ea7\u522b\u4e3aroot\u8eab\u4efd\u300f\u5f53\u7136\uff0c\u4f60\u4e5f\u53ef\u4ee5\u5c06\u8fd9\u4e00\u884c\u6539\u4e3a\u6210\u5176\u4ed6\u7684\u8eab\u4efd\uff01\u800c\u00a0run-parts\u4ee3\u8868\u540e\u9762\u63a5\u7684 \/etc\/cron.hourly \u662f\u300e\u4e00\u4e2a\u76ee\u5f55\u5185\uff08\/etc\/cron.hourly\uff09\u7684\u6240\u6709\u53ef\u6267\u884c\u6587\u4ef6\u300f\uff0c\u4e5f\u5c31\u662f\u8bf4\uff0c\u6bcf\u4e2a\u5c0f\u65f6\u768401\u5206\uff0c\u7cfb\u7edf\u4f1a\u4ee5root\u8eab\u4efd\u53bb\/etc\/cron.hourly\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u6267\u884c\u6240\u6709\u53ef\u6267\u884c\u7684\u6587\u4ef6\uff01\u540e\u9762\u4e09\u884c\u4e5f\u662f\u7c7b\u4f3c\u7684\u610f\u601d\uff01\u4f60\u53ef\u4ee5\u5230 \/etc\/ \u5e95\u4e0b\u53bb\u770b\u770b\uff0c\u7cfb\u7edf\u672c\u6765\u5c31\u9884\u8bbe\u4e86\u8fd94\u4e2a\u76ee\u5f55\uff01\u4f60\u53ef\u4ee5\u5c06\u6bcf\u5929\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u76f4\u63a5\u5199\u5230\/etc\/cron.daily\u5373\u53ef\uff0c\u8fd8\u4e0d\u9700\u8981\u4f7f\u7528\u5230crontab -e\u7684\u7a0b\u5f0f\uff01<\/span><\/p>\n<\/li>\n<\/ul>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><br style=\"box-sizing: border-box;\" \/><span style=\"box-sizing: border-box; font-weight: bold;\">\u56db\u3001\/etc\/cron.d\/ \u8fd9\u4e2a\u76ee\u5f55\u7528\u6765\u5b58\u653e\u4efb\u4f55\u8981\u6267\u884c\u7684crontab\u6587\u4ef6\u6216\u811a\u672c\u3002<\/span><br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/><span style=\"box-sizing: border-box; font-weight: bold;\">\u4e94\u3001\u6743\u9650(\uff1f)<\/span><br style=\"box-sizing: border-box;\" \/>crontab\u6743\u9650\u95ee\u9898\u5230\/var\/adm\/cron\/\u4e0b\u4e00\u770b\uff0c\u6587\u4ef6cron.allow\u548ccron.deny\u662f\u5426\u5b58\u5728<br style=\"box-sizing: border-box;\" \/>\u7528\u6cd5\u5982\u4e0b\uff1a\u00a0<br style=\"box-sizing: border-box;\" \/>1\u3001\u5982\u679c\u4e24\u4e2a\u6587\u4ef6\u90fd\u4e0d\u5b58\u5728\uff0c\u5219\u53ea\u6709root\u7528\u6237\u624d\u80fd\u4f7f\u7528crontab\u547d\u4ee4\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>2\u3001\u5982\u679ccron.allow\u5b58\u5728\u4f46cron.deny\u4e0d\u5b58\u5728\uff0c\u5219\u53ea\u6709\u5217\u5728cron.allow\u6587\u4ef6\u91cc\u7684\u7528\u6237\u624d\u80fd\u4f7f\u7528crontab\u547d\u4ee4\uff0c\u5982\u679croot\u7528\u6237\u4e5f\u4e0d\u5728\u91cc\u9762\uff0c\u5219root\u7528\u6237\u4e5f\u4e0d\u80fd\u4f7f\u7528crontab\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>3\u3001\u5982\u679ccron.allow\u4e0d\u5b58\u5728, cron.deny\u5b58\u5728\uff0c\u5219\u53ea\u6709\u5217\u5728cron.deny\u6587\u4ef6\u91cc\u9762\u7684\u7528\u6237\u4e0d\u80fd\u4f7f\u7528crontab\u547d\u4ee4\uff0c\u5176\u5b83\u7528\u6237\u90fd\u80fd\u4f7f\u7528\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>4\u3001\u5982\u679c\u4e24\u4e2a\u6587\u4ef6\u90fd\u5b58\u5728\uff0c\u5219\u5217\u5728cron.allow\u6587\u4ef6\u4e2d\u800c\u4e14\u6ca1\u6709\u5217\u5728cron.deny\u4e2d\u7684\u7528\u6237\u53ef\u4ee5\u4f7f\u7528crontab\uff0c\u5982\u679c\u4e24\u4e2a\u6587\u4ef6\u4e2d\u90fd\u6709\u540c\u4e00\u4e2a\u7528\u6237\uff0c\u4ee5cron.allow\u6587\u4ef6\u91cc\u9762\u662f\u5426\u6709\u8be5\u7528\u6237\u4e3a\u51c6\uff0c\u5982\u679ccron.allow\u4e2d\u6709\u8be5\u7528\u6237\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528crontab\u547d\u4ee4\u3002\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>AIX \u4e2d \u666e\u901a\u7528\u6237\u9ed8\u8ba4\u90fd\u6709 crontab \u6743\u9650\uff0c\u5982\u679c\u8981\u9650\u5236\u7528\u6237\u4f7f\u7528 crontab ,\u5c31\u9700\u8981\u7f16\u8f91\/var\/adm\/cron\/cron.deny\u00a0<br style=\"box-sizing: border-box;\" \/>HP-UNIX \u4e2d\u9ed8\u8ba4\u666e\u901a\u7528\u6237\u6ca1\u5f97crontab \u6743\u9650 \uff0c\u8981\u60f3\u653e\u5f00\u666e\u901a\u7528\u6237\u7684crontab \u6743\u9650\u53ef\u4ee5\u7f16<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/><span style=\"box-sizing: border-box; font-weight: bold;\">\u516d\u3001\u521b\u5efacron\u811a\u672c<\/span><br style=\"box-sizing: border-box;\" \/>\u7b2c\u4e00\u6b65\uff1a\u5199cron\u811a\u672c\u6587\u4ef6,\u547d\u540d\u4e3acrontest.cron\u3002<br style=\"box-sizing: border-box;\" \/>15,30,45,59 * * * * echo &#8220;xgmtest&#8230;..&#8221; &gt;&gt; xgmtest.txt\u00a0\u00a0\u8868\u793a\uff0c\u6bcf\u969415\u5206\u949f\uff0c\u6267\u884c\u6253\u5370\u4e00\u6b21\u547d\u4ee4\u00a0<br style=\"box-sizing: border-box;\" \/>\u7b2c\u4e8c\u6b65\uff1a\u6dfb\u52a0\u5b9a\u65f6\u4efb\u52a1\u3002\u6267\u884c\u547d\u4ee4 \u201ccrontab crontest.cron\u201d\u3002\u641e\u5b9a\u00a0<br style=\"box-sizing: border-box;\" \/>\u7b2c\u4e09\u6b65\uff1a&#8221;crontab -l&#8221; \u67e5\u770b\u5b9a\u65f6\u4efb\u52a1\u662f\u5426\u6210\u529f\u6216\u8005\u68c0\u6d4b\/var\/spool\/cron\u4e0b\u662f\u5426\u751f\u6210\u5bf9\u5e94cron\u811a\u672c<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><br style=\"box-sizing: border-box;\" \/>\u6ce8\u610f\uff1a\u8fd9\u64cd\u4f5c\u662f\u76f4\u63a5\u66ff\u6362\u8be5\u7528\u6237\u4e0b\u7684crontab\uff0c\u800c\u4e0d\u662f\u65b0\u589e<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-weight: bold;\">\u4e03\u3001crontab\u7528\u6cd5\u00a0<\/span><br style=\"box-sizing: border-box;\" \/>\u3000\u3000crontab\u547d\u4ee4\u7528\u4e8e\u5b89\u88c5\u3001\u5220\u9664\u6216\u8005\u5217\u51fa\u7528\u4e8e\u9a71\u52a8cron\u540e\u53f0\u8fdb\u7a0b\u7684\u8868\u683c\u3002\u7528\u6237\u628a\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u5e8f\u5217\u653e\u5230crontab\u6587\u4ef6\u4e2d\u4ee5\u83b7\u5f97\u6267\u884c\u3002<br style=\"box-sizing: border-box;\" \/>\u00a0 \u00a0 \u6bcf\u4e2a\u7528\u6237\u90fd\u53ef\u4ee5\u6709\u81ea\u5df1\u7684crontab\u6587\u4ef6\u3002\/var\/spool\/cron\u4e0b\u7684crontab\u6587\u4ef6\u4e0d\u53ef\u4ee5\u76f4\u63a5\u521b\u5efa\u6216\u8005\u76f4\u63a5\u4fee\u6539\u3002\u8be5crontab\u6587\u4ef6\u662f\u901a\u8fc7crontab\u547d\u4ee4\u521b\u5efa\u7684<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u3000\u00a0\u00a0\u5728crontab\u6587\u4ef6\u4e2d\u5982\u4f55\u8f93\u5165\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4\u548c\u65f6\u95f4\u3002\u8be5\u6587\u4ef6\u4e2d\u6bcf\u884c\u90fd\u5305\u62ec\u516d\u4e2a\u57df\uff0c\u5176\u4e2d\u524d\u4e94\u4e2a\u57df\u662f\u6307\u5b9a\u547d\u4ee4\u88ab\u6267\u884c\u7684\u65f6\u95f4\uff0c\u6700\u540e\u4e00\u4e2a\u57df\u662f\u8981\u88ab\u6267\u884c\u7684\u547d\u4ee4\u3002<br style=\"box-sizing: border-box;\" \/>\u00a0 \u00a0 \u6bcf\u4e2a\u57df\u4e4b\u95f4\u4f7f\u7528\u7a7a\u683c\u6216\u8005\u5236\u8868\u7b26\u5206\u9694\u3002\u683c\u5f0f\u5982\u4e0b\uff1a\u00a0<br style=\"box-sizing: border-box;\" \/>\u3000\u3000minute hour day-of-month month-of-year day-of-week commands\u00a0<br style=\"box-sizing: border-box;\" \/>\u00a0 \u00a0\u00a0<span style=\"box-sizing: border-box; color: #ff0000;\">\u5408\u6cd5\u503c 00-59 00-23 01-31 01-12 0-6 (0 is sunday)\u00a0<\/span><br style=\"box-sizing: border-box;\" \/>\u00a0 \u00a0\u00a0<span style=\"box-sizing: border-box; color: #ff0000;\">\u9664\u4e86\u6570\u5b57\u8fd8\u6709\u51e0\u4e2a\u4e2a\u7279\u6b8a\u7684\u7b26\u53f7\u5c31\u662f&#8221;*&#8221;\u3001&#8221;\/&#8221;\u548c&#8221;-&#8220;\u3001&#8221;,&#8221;\uff0c*\u4ee3\u8868\u6240\u6709\u7684\u53d6\u503c\u8303\u56f4\u5185\u7684\u6570\u5b57\uff0c&#8221;\/&#8221;\u4ee3\u8868\u6bcf\u7684\u610f\u601d,&#8221;\/5&#8243;\u8868\u793a\u6bcf5\u4e2a\u5355\u4f4d\uff0c&#8221;-&#8220;\u4ee3\u8868\u4ece\u67d0\u4e2a\u6570\u5b57\u5230\u67d0\u4e2a\u6570\u5b57,&#8221;,&#8221;\u5206\u5f00\u51e0\u4e2a\u79bb\u6563\u7684\u6570\u5b57\u3002<\/span><br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u00a0 \u00a0 \u00a0 -l \u5728\u6807\u51c6\u8f93\u51fa\u4e0a\u663e\u793a\u5f53\u524d\u7684crontab\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>\u3000\u3000-r \u5220\u9664\u5f53\u524d\u7684crontab\u6587\u4ef6\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>\u3000\u3000-e \u4f7f\u7528VISUAL\u6216\u8005EDITOR\u73af\u5883\u53d8\u91cf\u6240\u6307\u7684\u7f16\u8f91\u5668\u7f16\u8f91\u5f53\u524d\u7684crontab\u6587\u4ef6\u3002\u5f53\u7ed3\u675f\u7f16\u8f91\u79bb\u5f00\u65f6\uff0c\u7f16\u8f91\u540e\u7684\u6587\u4ef6\u5c06\u81ea\u52a8\u5b89\u88c5\u3002<\/p>\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\">\n<p style=\"box-sizing: border-box; margin: 10px auto; color: #4b4b4b; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 13px; background-color: #ffffff;\"><span style=\"box-sizing: border-box; font-weight: bold;\">\u516b\u3001\u4f8b\u5b50\uff1a\u00a0<\/span><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5929\u65e9\u4e0a6\u70b9\u00a0<br style=\"box-sizing: border-box;\" \/>0 6 * * * echo &#8220;Good morning.&#8221; &gt;&gt; \/tmp\/test.txt \/\/\u6ce8\u610f\u5355\u7eafecho\uff0c\u4ece\u5c4f\u5e55\u4e0a\u770b\u4e0d\u5230\u4efb\u4f55\u8f93\u51fa\uff0c\u56e0\u4e3acron\u628a\u4efb\u4f55\u8f93\u51fa\u90fdemail\u5230root\u7684\u4fe1\u7bb1\u4e86\u3002<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u4e24\u4e2a\u5c0f\u65f6\u00a0<br style=\"box-sizing: border-box;\" \/>0 *\/2 * * * echo &#8220;Have a break now.&#8221; &gt;&gt; \/tmp\/test.txt\u00a0\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u665a\u4e0a11\u70b9\u5230\u65e9\u4e0a8\u70b9\u4e4b\u95f4\u6bcf\u4e24\u4e2a\u5c0f\u65f6\u548c\u65e9\u4e0a\u516b\u70b9\u00a0<br style=\"box-sizing: border-box;\" \/>0 23-7\/2\uff0c8 * * * echo &#8220;Have a good dream&#8221; &gt;&gt; \/tmp\/test.txt<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u4e2a\u6708\u76844\u53f7\u548c\u6bcf\u4e2a\u793c\u62dc\u7684\u793c\u62dc\u4e00\u5230\u793c\u62dc\u4e09\u7684\u65e9\u4e0a11\u70b9\u00a0<br style=\"box-sizing: border-box;\" \/>0 11 4 * 1-3 command line<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>1\u67081\u65e5\u65e9\u4e0a4\u70b9\u00a0<br style=\"box-sizing: border-box;\" \/>0 4 1 1 * command line SHELL=\/bin\/bash PATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin MAILTO=root \/\/\u5982\u679c\u51fa\u73b0\u9519\u8bef\uff0c\u6216\u8005\u6709\u6570\u636e\u8f93\u51fa\uff0c\u6570\u636e\u4f5c\u4e3a\u90ae\u4ef6\u53d1\u7ed9\u8fd9\u4e2a\u5e10\u53f7 HOME=\/\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5c0f\u65f6\u6267\u884c\/etc\/cron.hourly\u5185\u7684\u811a\u672c<br style=\"box-sizing: border-box;\" \/>01 * * * * root run-parts \/etc\/cron.hourly<br style=\"box-sizing: border-box;\" \/>\u6bcf\u5929\u6267\u884c\/etc\/cron.daily\u5185\u7684\u811a\u672c<br style=\"box-sizing: border-box;\" \/>02 4 * * * root run-parts \/etc\/cron.daily\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u661f\u671f\u6267\u884c\/etc\/cron.weekly\u5185\u7684\u811a\u672c<br style=\"box-sizing: border-box;\" \/>22 4 * * 0 root run-parts \/etc\/cron.weekly\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u6708\u53bb\u6267\u884c\/etc\/cron.monthly\u5185\u7684\u811a\u672c\u00a0<br style=\"box-sizing: border-box;\" \/>42 4 1 * * root run-parts \/etc\/cron.monthly\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6ce8\u610f: &#8220;run-parts&#8221;\u8fd9\u4e2a\u53c2\u6570\u4e86\uff0c\u5982\u679c\u53bb\u6389\u8fd9\u4e2a\u53c2\u6570\u7684\u8bdd\uff0c\u540e\u9762\u5c31\u53ef\u4ee5\u5199\u8981\u8fd0\u884c\u7684\u67d0\u4e2a\u811a\u672c\u540d\uff0c\u800c\u4e0d\u662f\u6587\u4ef6\u5939\u540d\u3002 \u3000\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5929\u7684\u4e0b\u53484\u70b9\u30015\u70b9\u30016\u70b9\u76845 min\u300115 min\u300125 min\u300135 min\u300145 min\u300155 min\u65f6\u6267\u884c\u547d\u4ee4\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>5\uff0c15\uff0c25\uff0c35\uff0c45\uff0c55 16\uff0c17\uff0c18 * * * command<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5468\u4e00\uff0c\u4e09\uff0c\u4e94\u7684\u4e0b\u53483\uff1a00\u7cfb\u7edf\u8fdb\u5165\u7ef4\u62a4\u72b6\u6001\uff0c\u91cd\u65b0\u542f\u52a8\u7cfb\u7edf\u3002<br style=\"box-sizing: border-box;\" \/>00 15 * * 1\uff0c3\uff0c5 shutdown -r +5<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5c0f\u65f6\u768410\u5206\uff0c40\u5206\u6267\u884c\u7528\u6237\u76ee\u5f55\u4e0b\u7684innd\/bbslin\u8fd9\u4e2a\u6307\u4ee4\uff1a\u00a0<br style=\"box-sizing: border-box;\" \/>10\uff0c40 * * * * innd\/bbslink\u00a0<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5c0f\u65f6\u76841\u5206\u6267\u884c\u7528\u6237\u76ee\u5f55\u4e0b\u7684bin\/account\u8fd9\u4e2a\u6307\u4ee4\uff1a\u00a0<br style=\"box-sizing: border-box;\" \/>1 * * * * bin\/account<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5929\u65e9\u6668\u4e09\u70b9\u4e8c\u5341\u5206\u6267\u884c\u7528\u6237\u76ee\u5f55\u4e0b\u5982\u4e0b\u6240\u793a\u7684\u4e24\u4e2a\u6307\u4ee4\uff08\u6bcf\u4e2a\u6307\u4ee4\u4ee5;\u5206\u9694\uff09\uff1a\u00a0<br style=\"box-sizing: border-box;\" \/>20 3 * * * \uff08\/bin\/rm -f expire.ls logins.bad;bin\/expire$#@62;expire.1st\uff09\u3000\u3000<br style=\"box-sizing: border-box;\" \/><br style=\"box-sizing: border-box;\" \/>\u6bcf\u5e74\u7684\u4e00\u6708\u548c\u56db\u6708\uff0c4\u53f7\u52309\u53f7\u76843\u70b912\u5206\u548c3\u70b955\u5206\u6267\u884c\/bin\/rm -f expire.1st\u8fd9\u4e2a\u6307\u4ee4\uff0c\u5e76\u628a\u7ed3\u679c\u6dfb\u52a0\u5728mm.txt\u8fd9\u4e2a\u6587\u4ef6\u4e4b\u540e\uff08mm.txt\u6587\u4ef6\u4f4d\u4e8e\u7528\u6237\u81ea\u5df1\u7684\u76ee\u5f55\u4f4d\u7f6e\uff09\u3002\u00a0<br style=\"box-sizing: border-box;\" \/>12,55 3 4-9 1,4 * \/bin\/rm -f expire.1st$#@62;$#@62;mm.txt<\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\">\u6bcf\u5c0f\u65f6\u91cd\u542f<\/p>\n<p style=\"box-sizing: border-box; margin: 0px 0px 10px; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 14px; background-color: #ffffff;\">0 *\/1 * * * shutdown -r now<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728LINUX\u4e2d\uff0c\u5468\u671f\u6267\u884c\u7684\u4efb\u52a1\u4e00\u822c\u7531cron\u8fd9\u4e2a\u5b88\u62a4\u8fdb\u7a0b\u6765\u5904\u7406[ps -ef|grep cron]\u3002cron\u8bfb [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[38,40,39],"class_list":["post-208","post","type-post","status-publish","format-standard","hentry","category-8","tag-crontab","tag-linux","tag-39"],"_links":{"self":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=208"}],"version-history":[{"count":0,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=\/wp\/v2\/posts\/208\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.djlog.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}