{"id":1889,"date":"2012-07-05T21:36:00","date_gmt":"2012-07-05T01:36:00","guid":{"rendered":""},"modified":"2012-07-05T21:36:00","modified_gmt":"2012-07-05T01:36:00","slug":"","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/1889.html","title":{"rendered":"\u751f\u4ea7\u73af\u5883\u4e0b\u7684crontab\u5199\u6cd5"},"content":{"rendered":"<p><html><head><meta http-equiv=\"Content-Type\" content=\"text\/html; charset=utf-8\" \/><title>\u751f\u4ea7\u73af\u5883\u4e0b\u7684crontab\u5199\u6cd5<\/title><\/head><body><\/p>\n<h1 style=\"display:none\">\u751f\u4ea7\u73af\u5883\u4e0b\u7684crontab\u5199\u6cd5<\/h1>\n<div>\n<p><span style=\"font-size: 14px;\">\u867d\u7136\u5173\u4e8e Crontab \u7684\u4ecb\u7ecd\u5230\u5904\u90fd\u662f\uff0c\u8be6\u7ec6\u8bfb\u4e86\u4e00\u904d\u8fd9\u4e2a\u8bcd\u6761\uff0c\u6536\u83b7\u8fd8\u662f\u6709\u7684\u3002Crontab\u8fd9\u4e2a\u540d\u5b57\u6765\u81ea \u201cchronos\u201d\uff0c\u4e00\u4e2a\u53e4\u5e0c\u814a\u8bed, \u201c\u65f6\u95f4\u201d\u7684\u610f\u601d<\/span><br \/><span style=\"font-size: 14px;\">\u5e38\u89c1\u9677\u9631<\/span><br \/><span style=\"font-size: 14px;\">\u6bcf\u4e2aSA\u3001DBA \u6216\u8005\u662f\u666e\u901a\u7684 Unix \u7528\u6237\uff0c\u5728\u7b2c\u4e00\u6b21\u4f7f\u7528 Crontab \u7684\u65f6\u5019\u90fd\u4f1a\u9047\u5230\u95ee\u9898. \u8fd0\u884c Crontab \u7684\u5e38\u89c1\u9519\u8bef\u5305\u62ec\u5982\u4e0b\u51e0\u79cd:1) \u51fa\u4e8e\u6d4b\u8bd5\u76ee\u7684\u65b0\u521b\u5efa\u4e86\u4e00\u6761 Cron JOB, \u65f6\u95f4\u95f4\u9694\u5fc5\u987b\u8d85\u8fc7\u4e24\u5206\u949f\uff0c\u5426\u5219 JOB \u5c06\u8c03\u5ea6\u4e0d\u5230\u3002\u5982\u679c\u5fc5\u987b\u5ffd\u7565\u8fd9\u4e24\u5206\u949f\u7684\u8f7d\u5165\u914d\u7f6e\u65f6\u95f4\u5dee\uff0c\u53ef\u4ee5\u901a\u8fc7\u91cd\u65b0\u542f\u52a8 Cron Daemon \u505a\u5230\u3002<\/span><br \/><span style=\"font-size: 14px;\">2) \u4ece Crontab \u4e2d\u542f\u52a8 X Window \u7a0b\u5e8f\u9700\u8981\u6ce8\u610f\u7684\u4e8b\u9879\uff1a\u6240\u4ee5\u8981\u4e48\u5728\u7a0b\u5e8f\u524d\u521d\u59cb\u5316 \u201cDISPLAY=:0.0\u2033, \u8981\u4e48\u5728\u5e94\u7528\u7a0b\u5e8f\u540e\u9762\u8ffd\u52a0\u53c2\u6570 \u2013display :0.0<\/span><br \/><span style=\"font-size: 14px;\">3) \u547d\u4ee4\u4e2d\u7684 % \u5fc5\u987b\u505a\u8f6c\u4e49\u5904\u7406: \\% .\u6211\u4e2a\u4eba\u7684\u610f\u89c1\u662f\u4e0d\u8981\u5728\u547d\u4ee4\u884c\u91cc\u5e26\u8fd9\u4e2a\u53c2\u6570\uff0c\u5e72\u8106\u5199\u5230\u811a\u672c\u91cc\uff0c\u7136\u540e\u8c03\u5ea6\u8be5\u811a\u672c\u5373\u53ef\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5176\u5b9e\u6211\u5012\u662f\u8ba4\u4e3a\u4f7f\u7528 Crontab \u6700\u5e38\u89c1\u7684\u4e00\u4e2a\u95ee\u9898\u5f80\u5f80\u662f\u56e0\u4e3a\u73af\u5883\u53d8\u91cf\u4e0d\u5bf9\u3002\u7ecf\u5e38\u4f1a\u770b\u5230\u8bba\u575b\u91cc\u6709\u4eba\u95ee\uff1a\u4e3a\u4ec0\u4e48\u6211\u7684 Crontab \u521b\u5efa\u4e86\u4e0d\u6267\u884c? \u51c6\u5907\u521b\u5efa\u4e00\u6761 Cron JOB \u7684\u65f6\u5019\uff0c\u5f88\u591a\u4eba\u90fd\u559c\u6b22\u5728\u547d\u4ee4\u884c\u4e0b\u8fd0\u884c\u4e00\u904d\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u65f6\u5019\u73af\u5883\u53d8\u91cf\u662f\u968f\u7740 Shell \u81ea\u52a8\u5e26\u8fdb\u6765\uff0c\u5728 Crontab \u4e2d\u5219\u53ef\u80fd\u56e0\u4e3a\u627e\u4e0d\u5230\u6b63\u786e\u7684\u73af\u5883\u53d8\u91cf\uff0cJOB \u5c31\u4e0d\u80fd\u6267\u884c\u3002\u8fd9\u4e2a\u5c0f\u95ee\u9898\u5c31\u50cf\u51fa\u5929\u82b1\uff0c\u4e00\u6b21\u6559\u8bad\u4e4b\u540e\u5c31\u90fd\u8bb0\u5f97\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5fc5\u987b\u4f7f\u7528\u7684\u4e00\u5219\u6280\u5de7<\/span><br \/><span style=\"font-size: 14px;\">\u6bcf\u6761 JOB \u6267\u884c\u5b8c\u6bd5\u4e4b\u540e\uff0c\u7cfb\u7edf\u4f1a\u81ea\u52a8\u5c06\u8f93\u51fa\u53d1\u9001\u90ae\u4ef6\u7ed9\u5f53\u524d\u7cfb\u7edf\u7528\u6237\u3002\u65e5\u79ef\u6708\u7d2f\uff0c\u975e\u5e38\u7684\u591a\uff0c\u751a\u81f3\u4f1a\u6491\u7206\u6574\u4e2a\u7cfb\u7edf\u3002\u6240\u4ee5\u6bcf\u6761 JOB \u547d\u4ee4\u540e\u9762\u8fdb\u884c\u91cd\u5b9a\u5411\u5904\u7406\u662f\u975e\u5e38\u5fc5\u8981\u7684\uff1a &gt;&gt;\/dev\/null 2&gt;&amp;1 \u3002\u524d\u63d0\u662f\u5bf9 Job \u4e2d\u7684\u547d\u4ee4\u9700\u8981\u6b63\u5e38\u8f93\u51fa\u5df2\u7ecf\u4f5c\u4e86\u4e00\u5b9a\u7684\u5904\u7406, \u6bd4\u5982\u8ffd\u52a0\u5230\u67d0\u4e2a\u7279\u5b9a\u65e5\u5fd7\u6587\u4ef6\u3002\u9644: Crontab \u7684\u683c\u5f0f\u8bf4\u660e\u5982\u4e0b:<\/span><br \/><span style=\"font-size: 14px;\">* \u9017\u53f7(\u2019,&#8217;) \u6307\u5b9a\u5217\u8868\u503c\u3002\u5982: \u201c1,3,4,7,8\u2033<\/span><br \/><span style=\"font-size: 14px;\">* \u4e2d\u6a2a\u7ebf(\u2019-&#8216;) \u6307\u5b9a\u8303\u56f4\u503c \u5982 \u201c1-6\u2033, \u4ee3\u8868 \u201c1,2,3,4,5,6\u2033<\/span><br \/><span style=\"font-size: 14px;\">* \u661f\u53f7 (\u2019*&#8217;) \u4ee3\u8868\u6240\u6709\u53ef\u80fd\u7684\u503c<\/span><\/p>\n<p><span style=\"font-size: 14px;\">Linux(\u5f00\u6e90\u7cfb\u7edf\u4f3c\u4e4e\u90fd\u53ef\u4ee5)\u4e0b\u8fd8\u6709\u4e2a \u201c\/\u201d \u53ef\u4ee5\u7528. \u5728 Minute \u5b57\u6bb5\u4e0a\uff0c*\/15 \u8868\u793a\u6bcf 15 \u5206\u949f\u6267\u884c\u4e00\u6b21\u3002\u800c\u8fd9\u4e2a\u7279\u6027\u5728\u5546\u4e1a Unix \uff0c\u6bd4\u5982 AIX \u4e0a\u5c31\u6ca1\u6709.<\/span><br \/><span style=\"font-size: 14px;\">## Use the hash sign to prefix a comment<\/span><br \/><span style=\"font-size: 14px;\"># +&#8212;&#8212;&#8212;&#8212;&#8212;- minute (0 &#8211; 59)<\/span><br \/><span style=\"font-size: 14px;\"># | +&#8212;&#8212;&#8212;&#8212;- hour (0 &#8211; 23)<\/span><br \/><span style=\"font-size: 14px;\"># | | +&#8212;&#8212;&#8212;- day of month (1 &#8211; 31)<\/span><br \/><span style=\"font-size: 14px;\"># | | | +&#8212;&#8212;- month (1 &#8211; 12)<\/span><br \/><span style=\"font-size: 14px;\"># | | | | +&#8212;- day of week (0 &#8211; 7) (Sunday=0 or 7)<\/span><br \/><span style=\"font-size: 14px;\"># | | | | |<\/span><br \/><span style=\"font-size: 14px;\"># * * * * * command to be executed \u63a8\u8350\u8bb0\u5fc6\u4e3a\u5206 \u65f6 \u65e5 \u6708 \u661f\u671f<\/span><\/p>\n<p><span style=\"font-size: 14px;\">cron\u6765\u6e90\u4e8e\u5e0c\u814a\u5355\u8bcdchronos\uff08\u610f\u4e3a\u201c\u65f6\u95f4\u201d\uff09\uff0c\u662flinux\u7cfb\u7edf\u4e0b\u4e00\u4e2a\u81ea\u52a8\u6267\u884c\u6307\u5b9a\u4efb\u52a1\u7684\u7a0b\u5e8f\u3002\u4f8b\u5982\uff0c\u4f60\u60f3\u5728\u6bcf\u665a\u7761\u89c9\u671f\u95f4\u521b\u5efa\u67d0\u4e9b\u6587\u4ef6\u6216\u6587\u4ef6\u5939\u7684\u5907\u4efd\uff0c\u5c31\u53ef\u4ee5\u7528cron\u6765\u81ea\u52a8\u6267\u884c\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u670d\u52a1\u7684\u542f\u52a8\u548c\u505c\u6b62<\/span><br \/><span style=\"font-size: 14px;\">cron\u670d\u52a1\u662flinux\u7684\u5185\u7f6e\u670d\u52a1\uff0c\u4f46\u5b83\u4e0d\u4f1a\u5f00\u673a\u81ea\u52a8\u542f\u52a8\u3002\u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u548c\u505c\u6b62\u670d\u52a1\uff1a<\/span><br \/><span style=\"font-size: 14px;\">\/sbin\/service crond start<\/span><br \/><span style=\"font-size: 14px;\">\/sbin\/service crond stop<\/span><br \/><span style=\"font-size: 14px;\">\/sbin\/service crond restart<\/span><br \/><span style=\"font-size: 14px;\">\/sbin\/service crond reload<\/span><br \/><span style=\"font-size: 14px;\">\u4ee5\u4e0a1-4\u884c\u5206\u522b\u4e3a\u542f\u52a8\u3001\u505c\u6b62\u3001\u91cd\u542f\u670d\u52a1\u548c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u8981\u628acron\u8bbe\u4e3a\u5728\u5f00\u673a\u7684\u65f6\u5019\u81ea\u52a8\u542f\u52a8\uff0c\u5728 \/etc\/rc.d\/rc.local \u811a\u672c\u4e2d\u52a0\u5165 \/sbin\/service crond start \u5373\u53ef\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u67e5\u770b\u3001\u7f16\u8f91\u548c\u5220\u9664<\/span><br \/><span style=\"font-size: 14px;\">cron\u628a\u547d\u4ee4\u884c\u4fdd\u5b58\u5728crontab\uff08cron table\uff09\u6587\u4ef6\u91cc\uff0c\u8fd9\u4e2a\u6587\u4ef6\u901a\u5e38\u5728 \/etc \u76ee\u5f55\u4e0b\u3002\u6bcf\u4e2a\u7cfb\u7edf\u7528\u6237\u90fd\u53ef\u4ee5\u6709\u81ea\u5df1\u7684crontab\uff08\u5728 \/var\/spool\/cron\/ \u4e0b\uff09\u3002\u8981\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684crontab\uff0c\u8f93\u5165 crontab -l\uff1b\u8981\u7f16\u8f91crontab\uff0c\u8f93\u5165 crontab -e\uff1b\u8981\u5220\u9664crontab\uff0c\u8f93\u5165 crontab -r\u3002\u5982\u5f53\u524d\u662froot\u8eab\u4efd\uff0c\u8981\u67e5\u770b\/\u7f16\u8f91\/\u5220\u9664\/\u67d0\u7528\u6237\u7684crontab\uff0c\u53ea\u9700\u5728\u76f8\u5e94\u7684\u547d\u4ee4\u540e\u52a0\u4e0a -u USERNAME\uff08\u5982 crontab -e -u USERNAME\uff09\u5373\u53ef\u3002crontab\u6587\u4ef6\u7684\u9ed8\u8ba4\u7f16\u8f91\u5668\u662fvi\uff0c\u53ef\u4ee5\u8f93\u5165 export VISUAL=&#8217;editor&#8217; \u66f4\u6539\u9ed8\u8ba4\u7f16\u8f91\u5668\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">cron\u670d\u52a1\u6bcf\u5206\u949f\u4e0d\u4ec5\u8981\u8bfb\u4e00\u6b21 \/var\/spool\/cron \u76ee\u5f55\u5185\u7684\u6240\u6709\u6587\u4ef6\uff0c\u8fd8\u9700\u8981\u8bfb\u4e00\u6b21 \/etc\/crontab \u6587\u4ef6\u3002\u914d\u7f6e\u8fd9\u4e2a\u6587\u4ef6\u4e5f\u80fd\u8ba9cron\u6267\u884c\u4efb\u52a1\u3002\u4f7f\u7528crontab\u547d\u4ee4\u662f\u5bf9\u7528\u6237\u7ea7\u4efb\u52a1\u7684\u914d\u7f6e\uff0c\u800c\u7f16\u8f91 \/etc\/crontab \u6587\u4ef6\u662f\u5bf9\u7cfb\u7edf\u7ea7\u4efb\u52a1\u7684\u914d\u7f6e\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u8bed\u6cd5\u8bf4\u660e<\/span><br \/><span style=\"font-size: 14px;\">\u4ee5\u4e0b\u662f\u4e24\u4e2acron\u8bed\u53e5\u7684\u4f8b\u5b50\uff08\u5728 \/etc\/crontab \u6587\u4ef6\u91cc\uff09\u3002\u524d\u8005\u7528\u6765\u665a\u95f4\u5907\u4efd \/etc \u76ee\u5f55\uff0c\u540e\u8005\u8fd0\u884cAnalog\u7a0b\u5e8f\u5904\u7406\u670d\u52a1\u5668\u7684\u7edf\u8ba1\u4fe1\u606f\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">12 3 * * * root tar czf \/usr\/local\/backups\/daily\/etc.tar.gz \/etc &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><br \/><span style=\"font-size: 14px;\">52 5 * * * root \/usr\/local\/src\/analog-5.32-lh\/analog &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><br \/><span style=\"font-size: 14px;\">\u4ee5\u4e0b\u662fcron\u8bed\u53e5\u4e2d\u7684\u5b57\u6bb5\u4e0e\u5b57\u6bb5\u8bf4\u660e\uff1a<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5b57\u6bb5 \u8bf4\u660e<\/span><br \/><span style=\"font-size: 14px;\">1 \u5206\u949f\uff080-59\uff09<\/span><br \/><span style=\"font-size: 14px;\">2 \u5c0f\u65f6\uff082-24\uff09<\/span><br \/><span style=\"font-size: 14px;\">3 \u65e5\u671f\uff081-31\uff09<\/span><br \/><span style=\"font-size: 14px;\">4 \u6708\u4efd\uff081-12\uff1b\u6216\u82f1\u6587\u7f29\u5199Jan\u3001Feb\u7b49\uff09<\/span><br \/><span style=\"font-size: 14px;\">5 \u5468\u51e0\uff080-6\uff0c0\u4e3a\u5468\u65e5\uff1b\u6216\u5355\u8bcd\u7f29\u5199Sun\u3001Mon\u7b49\uff09<\/span><br \/><span style=\"font-size: 14px;\">6 \u7528\u6237\u540d\uff08\u6267\u884c\u547d\u4ee4\u65f6\u4ee5\u6b64\u7528\u6237\u7684\u8eab\u4efd\uff09<\/span><br \/><span style=\"font-size: 14px;\">7 \u8981\u6267\u884c\u7684\u547d\u4ee4\uff08\u8def\u5f84\uff09<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u73b0\u5728\u6765\u770b\u7b2c\u4e00\u884c\uff1a<\/span><br \/><span style=\"font-size: 14px;\">12 3 * * * root tar czf \/usr\/local\/backups\/daily\/etc.tar.gz \/etc &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><br \/><span style=\"font-size: 14px;\">\u8fd9\u6761\u8bed\u53e5\u5c06\u5728\u6bcf\u5929\u7684\u51cc\u66683\u70b912\u5206\uff0803:12\uff09\u8fd0\u884c tar czf \/usr\/local\/backups\/daily\/etc.tar.gz \/etc \u547d\u4ee4\u3002&gt;&gt; \/dev\/null 2&gt;&amp;1 \u8868\u793a\u628a\u6240\u6709\u6807\u51c6\u8f93\u51fa\u53d1\u9001\u5230 \/dev\/null\uff08linux\u7684\u56de\u6536\u7ad9\uff09\uff0c\u628a\u6807\u51c6\u9519\u8bef\u8f93\u51fa\uff082\uff09\u53d1\u9001\u5230\u548c\u6807\u51c6\u8f93\u51fa\uff081\uff09\u540c\u6837\u7684\u5730\u65b9\uff08\u5373 \/dev\/null\uff09\u3002\u8fd0\u884c\u8fd9\u884c\u547d\u4ee4\u5c06\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u8f93\u51fa\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u8fd9\u6761\u8bed\u53e5\u53ef\u4ee5\u53d8\u5f97\u7a0d\u5fae\u590d\u6742\u4e00\u70b9\uff1a<\/span><br \/><span style=\"font-size: 14px;\">30 15 13 6 1 * root tar czf \/usr\/local\/backups\/daily\/etc.tar.gz \/etc &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><br \/><span style=\"font-size: 14px;\">\u5b83\u5c06\u57286\u670813\u65e5\u5468\u4e00\u768415:30\u8fd0\u884c tar czf \/usr\/local\/backups\/daily\/etc.tar.gz \/etc \u547d\u4ee4\u3002<\/span><br \/><span style=\"font-size: 14px;\">\u4ee5\u4e0b\u8bed\u53e5\u53ef\u4ee5\u8fbe\u5230\u540c\u6837\u7684\u6548\u679c\uff1a<\/span><br \/><span style=\"font-size: 14px;\">30 15 13 Jun Mon * root tar czf \/usr\/local\/backups\/daily\/etc.tar.gz \/etc &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5982\u679c\u4f60\u60f3\u4ee5\u7528\u6237joey\u7684\u8eab\u4efd\u6bcf\u5c0f\u65f6\u7684\u7b2c15\u5206\u949f\u8fd0\u884c\u67d0\u4e2a\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/span><br \/><span style=\"font-size: 14px;\">15 * * * * joey \/usr\/bin\/somecommand &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><br \/><span style=\"font-size: 14px;\">\u5176\u4e2d\u7684\u661f\u53f7\uff08*\uff09\u662f\u901a\u914d\u7b26\uff0c\u8868\u793acron\u5c06\u5ffd\u7565\u8fd9\u4e2a\u5b57\u6bb5\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5982\u679c\u4f60\u60f3\u6bcf\u4e24\u5c0f\u65f6\u5c31\u8fd0\u884c\u67d0\u4e2a\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u5728\u5c0f\u65f6\u5b57\u6bb5\u91cc\u4f7f\u7528 *\/2\u3002\u5b83\u5c06\u4f1a\u57282\u70b9\uff0c4\u70b9\uff0c6\u70b9\u2026\u202622\u70b9\uff0c24\u70b9\u8fd0\u884c\u3002\u5177\u4f53\u8bed\u53e5\u5982\u4e0b\uff1a<\/span><br \/><span style=\"font-size: 14px;\">0 *\/2 * * * joey \/usr\/bin\/somecommand &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><\/p>\n<p><span style=\"font-size: 14px;\">cron\u8bed\u53e5\u4e2d\u8fd8\u53ef\u4ee5\u4f7f\u7528\u9017\u53f7\uff08,\uff09\u6765\u6307\u5b9a\u591a\u4e2a\u65f6\u95f4\u3002\u4f8b\u5982\u4f60\u60f3\u5728\u6bcf\u5c0f\u65f6\u768415\u5206\u548c30\u5206\u8fd0\u884c\u67d0\u4e2a\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u5728\u5206\u949f\u5b57\u6bb5\u4f7f\u7528 15,30\uff1a<\/span><br \/><span style=\"font-size: 14px;\">15,30 * * * * joey \/usr\/bin\/somecommand &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5982\u679c\u4f60\u60f3\u5728\u6bcf\u6708\u7684\u7b2c\u4e00\u5468\uff08\u53731\u53f7\u52307\u53f7\uff09\u6bcf\u5929\u7684\u6307\u5b9a\u65f6\u95f4\u8fd0\u884c\u67d0\u4e2a\u7a0b\u5e8f\uff0c\u53ef\u4ee5\u5728\u65e5\u671f\u5b57\u6bb5\u4f7f\u7528 1-7\uff1a<\/span><br \/><span style=\"font-size: 14px;\">15,30 *\/2 1-7 * * joey \/usr\/bin\/somecommand &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><br \/><span style=\"font-size: 14px;\">\u8fd9\u6761\u8bed\u53e5\u5c06\u5728\u6bcf\u6708\u7684\u7b2c1-7\u65e5\u6bcf\u4e24\u5c0f\u65f6\u768415\u5206\u548c30\u5206\uff0802:15\uff0c02:30\u2026\u202622: 15\uff0c22:30\u7b49\uff09\u8fd0\u884c \/usr\/bin\/somecommand \u547d\u4ee4\u3002<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5982\u679c\u4f60\u60f3\u5728\u6bcf\u5929\u768416:18\u6267\u884c\u4e00\u4e2a\u811a\u672c\u96c6\u5408\uff0c\u53ef\u4ee5\u628a\u6240\u6709\u8981\u6267\u884c\u7684\u811a\u672c\u653e\u5230\u4e00\u4e2a\u76ee\u5f55\u4e2d\uff08\u5982 \/home\/username\/cron\uff09\uff0c\u53ef\u4ee5\u4f7f\u7528\uff1a<\/span><br \/><span style=\"font-size: 14px;\">18 16 * * * root run-parts \/home\/username\/cron &gt;&gt; \/dev\/null 2&gt;&amp;1<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u5982\u679c\u4f60\u60f3\u4fdd\u5b58\u67d0\u4e2a\u7a0b\u5e8f\u7684\u8f93\u51fa\u7ed3\u679c\uff0c \u53ef\u4ee5\u628a &gt;&gt; \/dev\/null 2&gt;&amp;1 \u66ff\u6362\u4e3a &gt;&gt; \/home\/user\/somecommand.log 2&gt;&amp;1&nbsp;<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u603b\u7ed3<\/span><br \/><span style=\"font-size: 14px;\">\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684cron\u914d\u7f6e\uff0c\u4f7f\u7528crontab -l<\/span><br \/><span style=\"font-size: 14px;\">\u7f16\u8f91\u5f53\u524d\u7528\u6237\u7684cron\u914d\u7f6e\uff0c\u4f7f\u7528crontab -e<\/span><br \/><span style=\"font-size: 14px;\">\u5220\u9664\u5f53\u524d\u7528\u6237\u7684cron\u914d\u7f6e\uff0c\u4f7f\u7528crontab -r<\/span><br \/><span style=\"font-size: 14px;\">\u4ee5root\u8eab\u4efd\u67e5\u770b\/\u7f16\u8f91\/\u5220\u9664\u67d0\u7528\u6237\u7684cron\u914d\u7f6e\uff0c\u5728\u547d\u4ee4\u540e\u52a0\u4e0a-u USERNAME<\/span><br \/><span style=\"font-size: 14px;\">\u914d\u7f6e\u7cfb\u7edf\u7ea7\u7684\u4efb\u52a1\uff0c\u7f16\u8f91\/etc\/crontab\u6587\u4ef6<\/span><\/p>\n<p><span style=\"font-size: 14px;\">\u672c\u6587\u51fa\u81ea \u201c<\/span><a href=\"http:\/\/andrewyu.blog.51cto.com\/\"><span style=\"font-size: 14px;\">\u629a\u7434\u716e\u9152<\/span><\/a><span style=\"font-size: 14px;\">\u201d \u535a\u5ba2\uff0c\u8bf7\u52a1\u5fc5\u4fdd\u7559\u6b64\u51fa\u5904<\/span><a href=\"http:\/\/andrewyu.blog.51cto.com\/1604432\/502758\"><span style=\"font-size: 14px;\">http:\/\/andrewyu.blog.51cto.com\/1604432\/502758<\/span><\/a><\/p>\n<\/p>\n<\/div>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u751f\u4ea7\u73af\u5883\u4e0b\u7684crontab\u5199\u6cd5 \u751f\u4ea7\u73af\u5883\u4e0b\u7684crontab\u5199\u6cd5 \u867d\u7136\u5173\u4e8e Crontab \u7684\u4ecb\u7ecd\u5230\u5904\u90fd\u662f\uff0c\u8be6\u7ec6 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1889","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1889","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=1889"}],"version-history":[{"count":0,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1889\/revisions"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=1889"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=1889"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=1889"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}