{"id":70,"date":"2025-01-09T21:03:06","date_gmt":"2025-01-09T13:03:06","guid":{"rendered":"https:\/\/www.handytoo.com\/?p=70"},"modified":"2025-01-09T21:03:06","modified_gmt":"2025-01-09T13:03:06","slug":"linux-crontab%e6%9c%8d%e5%8a%a1%e4%bd%bf%e7%94%a8%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"http:\/\/www.handytoo.com\/?p=70","title":{"rendered":"Linux crontab\u670d\u52a1\u4f7f\u7528\u8bb0\u5f55"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u5e38\u7528\u547d\u4ee4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u76f4\u63a5\u7528crontab\u547d\u4ee4\u7f16\u8f91<\/h3>\n\n\n\n<p>cron\u670d\u52a1\u63d0\u4f9bcrontab\u547d\u4ee4\u6765\u8bbe\u5b9acron\u670d\u52a1\u7684\uff0c\u4ee5\u4e0b\u662f\u8fd9\u4e2a\u547d\u4ee4\u7684\u4e00\u4e9b\u53c2\u6570\u4e0e\u8bf4\u660e\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -u \/\/\u8bbe\u5b9a\u67d0\u4e2a\u7528\u6237\u7684cron\u670d\u52a1\uff0c\u4e00\u822croot\u7528\u6237\u5728\u6267\u884c\u8fd9\u4e2a\u547d\u4ee4\u7684\u65f6\u5019\u9700\u8981\u6b64\u53c2\u6570\ncrontab -l \/\/\u5217\u51fa\u67d0\u4e2a\u7528\u6237cron\u670d\u52a1\u7684\u8be6\u7ec6\u5185\u5bb9\ncrontab -r \/\/\u5220\u9664\u6ca1\u4e2a\u7528\u6237\u7684cron\u670d\u52a1\ncrontab -e \/\/\u7f16\u8f91\u67d0\u4e2a\u7528\u6237\u7684cron\u670d\u52a1\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u67e5\u770b<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -u root -l\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u5220\u9664<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -u fred -r\n<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">\u7f16\u8f91<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>crontab -u root -e<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">cron\u7684\u683c\u5f0f<\/h2>\n\n\n\n<p>\u7f16\u8f91\u7684\u5185\u5bb9\u4e00\u5b9a\u8981\u7b26\u5408\u4e0b\u9762\u7684\u683c\u5f0f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">*\/1 * * * * ls &gt;&gt; \/tmp\/ls.txt\n<\/pre>\n\n\n\n<p>\u8fd9\u4e2a\u683c\u5f0f\u7684\u524d\u4e00\u90e8\u5206\u662f\u5bf9\u65f6\u95f4\u7684\u8bbe\u5b9a\uff0c\u540e\u9762\u4e00\u90e8\u5206\u662f\u8981\u6267\u884c\u7684\u547d\u4ee4\uff0c\u5982\u679c\u8981\u6267\u884c\u7684\u547d\u4ee4\u592a\u591a\uff0c\u53ef\u4ee5\u628a\u8fd9\u4e9b\u547d\u4ee4\u5199\u5230\u4e00\u4e2a\u811a\u672c\u91cc\u9762\uff0c\u7136\u540e\u5728\u8fd9\u91cc\u76f4\u63a5\u8c03\u7528\u8fd9\u4e2a\u811a\u672c\u5c31\u53ef\u4ee5\u4e86\uff0c\u8c03\u7528\u7684\u65f6\u5019\u8bb0\u5f97\u5199\u51fa\u547d\u4ee4\u7684\u5b8c\u6574\u8def\u5f84\u3002\u65f6\u95f4\u7684\u8bbe\u5b9a\u6211\u4eec\u6709\u4e00\u5b9a\u7684\u7ea6\u5b9a\uff0c\u524d\u9762\u4e94\u4e2a*\u53f7\u4ee3\u8868\u4e94\u4e2a\u6570\u5b57\uff0c\u6570\u5b57\u7684\u53d6\u503c\u8303\u56f4\u548c\u542b\u4e49\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\u5206\u949f\uff080-59\uff09\n\u5c0f\u6642\uff080-23\uff09\n\u65e5\u671f\uff081-31\uff09\n\u6708\u4efd\uff081-12\uff09\n\u661f\u671f\uff080-6\uff09\/\/0\u4ee3\u8868\u661f\u671f\u5929\n<\/pre>\n\n\n\n<p>\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\u4ee5\u4e0b\u4e3e\u51e0\u4e2a\u4f8b\u5b50\u8bf4\u660e\u95ee\u9898\uff1a<\/p>\n\n\n\n<p>\u6bcf\u5929\u65e9\u4e0a6\u70b9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0 6 * * * echo \"Good morning.\" &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\n\n<\/pre>\n\n\n\n<p>\u6bcf\u4e24\u4e2a\u5c0f\u65f6<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0 *\/2 * * * echo \"Have a break now.\" &gt;&gt; \/tmp\/test.txt\n<\/pre>\n\n\n\n<p>\u665a\u4e0a11\u70b9\u5230\u65e9\u4e0a8\u70b9\u4e4b\u95f4\u6bcf\u4e24\u4e2a\u5c0f\u65f6\uff0c\u65e9\u4e0a\u516b\u70b9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0 23-7\/2\uff0c8 * * * echo \"Have a good dream\uff1a\uff09\" &gt;&gt; \/tmp\/test.txt\n<\/pre>\n\n\n\n<p>\u6bcf\u4e2a\u6708\u76844\u53f7\u548c\u6bcf\u4e2a\u793c\u62dc\u7684\u793c\u62dc\u4e00\u5230\u793c\u62dc\u4e09\u7684\u65e9\u4e0a11\u70b9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0 11 4 * 1-3 command line\n<\/pre>\n\n\n\n<p>1\u67081\u65e5\u65e9\u4e0a4\u70b9<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">0 4 1 1 * command line\n<\/pre>\n\n\n\n<p>\u6bcf\u6b21\u7f16\u8f91\u5b8c\u67d0\u4e2a\u7528\u6237\u7684cron\u8bbe\u7f6e\u540e\uff0ccron\u81ea\u52a8\u5728\/var\/spool\/cron\u4e0b\u751f\u6210\u4e00\u4e2a\u4e0e\u6b64\u7528\u6237\u540c\u540d\u7684\u6587\u4ef6\uff0c\u6b64\u7528\u6237\u7684cron\u4fe1\u606f\u90fd\u8bb0\u5f55\u5728\u8fd9\u4e2a\u6587\u4ef6\u4e2d\uff0c\u8fd9\u4e2a\u6587\u4ef6\u662f\u4e0d\u53ef\u4ee5\u76f4\u63a5\u7f16\u8f91\u7684\uff0c\u53ea\u53ef\u4ee5\u7528crontab -e \u6765\u7f16\u8f91\u3002cron\u542f\u52a8\u540e\u6bcf\u8fc7\u4e00\u4efd\u949f\u8bfb\u4e00\u6b21\u8fd9\u4e2a\u6587\u4ef6\uff0c\u68c0\u67e5\u662f\u5426\u8981\u6267\u884c\u91cc\u9762\u7684\u547d\u4ee4\u3002\u56e0\u6b64\u6b64\u6587\u4ef6\u4fee\u6539\u540e\u4e0d\u9700\u8981\u91cd\u65b0\u542f\u52a8cron\u670d\u52a1\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u7f16\u8f91crontab\u6587\u4ef6\u914d\u7f6ecron<\/h2>\n\n\n\n<p>cron\u670d\u52a1\u6bcf\u5206\u949f\u4e0d\u4ec5\u8981\u8bfb\u4e00\u6b21\/var\/spool\/cron\u5185\u7684\u6240\u6709\u6587\u4ef6\uff0c\u8fd8\u9700\u8981\u8bfb\u4e00\u6b21\/etc\/crontab,\u56e0\u6b64\u6211\u4eec\u914d\u7f6e\u8fd9\u4e2a\u6587\u4ef6\u4e5f\u80fd\u8fd0\u7528 cron\u670d\u52a1\u505a\u4e00\u4e9b\u4e8b\u60c5\u3002\u7528crontab\u914d\u7f6e\u662f\u9488\u5bf9\u67d0\u4e2a\u7528\u6237\u7684\uff0c\u800c\u7f16\u8f91\/etc\/crontab\u662f\u9488\u5bf9\u7cfb\u7edf\u7684\u4efb\u52a1\u3002\u6b64\u6587\u4ef6\u7684\u6587\u4ef6\u683c\u5f0f\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>SHELL=\/bin\/bash\nPATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin\nMAILTO=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\nHOME=\/\n<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code># run-parts\n01 * * * * root run-parts \/etc\/cron.hourly \/\/\u6bcf\u4e2a\u5c0f\u65f6\u53bb\u6267\u884c\u4e00\u904d\/etc\/cron.hourly\u5185\u7684\u811a\u672c\n02 4 * * * root run-parts \/etc\/cron.daily \/\/\u6bcf\u5929\u53bb\u6267\u884c\u4e00\u904d\/etc\/cron.daily\u5185\u7684\u811a\u672c\n22 4 * * 0 root run-parts \/etc\/cron.weekly \/\/\u6bcf\u661f\u671f\u53bb\u6267\u884c\u4e00\u904d\/etc\/cron.weekly\u5185\u7684\u811a\u672c\n42 4 1 * * root run-parts \/etc\/cron.monthly \/\/\u6bcf\u4e2a\u6708\u53bb\u6267\u884c\u4e00\u904d\/etc\/cron.monthly\u5185\u7684\u811a\u672c\n<\/code><\/pre>\n\n\n\n<p>\u5927\u5bb6\u6ce8\u610f&#8221;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\u4e86\u3002\u5982\u679c\u4f60\u8fd8\u4e0d\u592a\u660e\u767d\uff0c\u770b\u4e0b\u9762\u7684\u5185\u5bb9\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>cron \u662f\u4e00\u4e2a\u53ef\u4ee5\u7528\u6765\u6839\u636e\u65f6\u95f4\u3001\u65e5\u671f\u3001\u6708\u4efd\u3001\u661f\u671f\u7684\u7ec4\u5408\u6765\u8c03\u5ea6\u5bf9\u91cd\u590d\u4efb\u52a1\u7684\u6267\u884c\u7684\u5b88\u62a4\u8fdb\u7a0b\u3002<\/li>\n\n\n\n<li>cron \u5047\u5b9a\u7cfb\u7edf\u6301\u7eed\u8fd0\u884c\u3002\u5982\u679c\u5f53\u67d0\u4efb\u52a1\u88ab\u8c03\u5ea6\u65f6\u7cfb\u7edf\u4e0d\u5728\u8fd0\u884c\uff0c\u8be5\u4efb\u52a1\u5c31\u4e0d\u4f1a\u88ab\u6267\u884c\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u8981\u4f7f\u7528 cron \u670d\u52a1\uff0c\u4f60\u5fc5\u987b\u5b89\u88c5\u4e86 vixie-cron RPM \u8f6f\u4ef6\u5305\uff0c\u800c\u4e14\u5fc5\u987b\u5728\u8fd0\u884c crond \u670d\u52a1\u3002\u8981\u5224\u5b9a\u8be5\u8f6f\u4ef6\u5305\u662f\u5426\u5df2\u5b89\u88c5\uff0c\u4f7f\u7528 rpm -q vixie-cron \u547d\u4ee4\u3002\u8981\u5224\u5b9a\u8be5\u670d\u52a1\u662f\u5426\u5728\u8fd0\u884c\uff0c\u4f7f\u7528 \/sbin\/service crond status \u547d\u4ee4\u3002\u524d\u56db\u884c\u662f\u7528\u6765\u914d\u7f6e cron \u4efb\u52a1\u8fd0\u884c\u73af\u5883\u7684\u53d8\u91cf\u3002 SHELL \u53d8\u91cf\u7684\u503c\u544a\u8bc9\u7cfb\u7edf\u8981\u4f7f\u7528\u54ea\u4e2a shell \u73af\u5883\uff08\u5728\u8fd9\u4e2a\u4f8b\u5b50\u91cc\u662f bash shell\uff09\uff1bPATH \u53d8\u91cf\u5b9a\u4e49\u7528\u6765\u6267\u884c\u547d\u4ee4\u7684\u8def\u5f84\u3002cron \u4efb\u52a1\u7684\u8f93\u51fa\u88ab\u90ae\u5bc4\u7ed9 MAILTO \u53d8\u91cf\u5b9a\u4e49\u7684\u7528\u6237\u540d\u3002\u5982\u679c MAILTO \u53d8\u91cf\u88ab\u5b9a\u4e49\u4e3a\u7a7a\u767d\u5b57\u7b26\u4e32\uff08MAILTO=&#8221;&#8221;\uff09\uff0c\u7535\u5b50\u90ae\u4ef6\u5c31\u4e0d\u4f1a\u88ab\u5bc4\u51fa\u3002HOME \u53d8\u91cf\u53ef\u4ee5\u7528\u6765\u8bbe\u7f6e\u5728\u6267\u884c\u547d\u4ee4\u6216\u811a\u672c\u65f6\u4f7f\u7528\u7684\u4e3b\u76ee\u5f55\u3002\/etc\/crontab \u6587\u4ef6\u4e2d\u7684\u6bcf\u4e00\u884c\u90fd\u4ee3\u8868\u4e00\u9879\u4efb\u52a1\uff0c\u5b83\u7684\u683c\u5f0f\u662f\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">minute hour day month dayofweek command\nminute \u2014 \u5206\u949f\uff0c\u4ece 0 \u5230 59 \u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\nhour \u2014 \u5c0f\u65f6\uff0c\u4ece 0 \u5230 23 \u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\nday \u2014 \u65e5\u671f\uff0c\u4ece 1 \u5230 31 \u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\uff08\u5982\u679c\u6307\u5b9a\u4e86\u6708\u4efd\uff0c\u5fc5\u987b\u662f\u8be5\u6708\u4efd\u7684\u6709\u6548\u65e5\u671f\uff09\nmonth \u2014 \u6708\u4efd\uff0c\u4ece 1 \u5230 12 \u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\uff08\u6216\u4f7f\u7528\u6708\u4efd\u7684\u82f1\u6587\u7b80\u5199\u5982 jan\u3001feb \u7b49\u7b49\uff09\ndayofweek \u2014 \u661f\u671f\uff0c\u4ece 0 \u5230 7 \u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\uff0c\u8fd9\u91cc\u7684 0 \u6216 7 \u4ee3\u8868\u661f\u671f\u65e5\uff08\u6216\u4f7f\u7528\u661f\u671f\u7684\u82f1\u6587\u7b80\u5199\u5982 sun\u3001mon \u7b49\u7b49\uff09\ncommand \u2014 \u8981\u6267\u884c\u7684\u547d\u4ee4\uff08\u5728\u4ee5\u4e0a\u4efb\u4f55\u503c\u4e2d\uff0c\u661f\u53f7\uff08*\uff09\u53ef\u4ee5\u7528\u6765\u4ee3\u8868\u6240\u6709\u6709\u6548\u7684\u503c\u3002\u8b6c\u5982\uff0c\u6708\u4efd\u503c\u4e2d\u7684\u661f\u53f7\u610f\u5473\u7740\u5728\u6ee1\u8db3\u5176\u5b83\u5236\u7ea6\u6761\u4ef6\u540e\u6bcf\u6708\u90fd\u6267\u884c\u8be5\u547d\u4ee4\u3002\n<\/pre>\n\n\n\n<p>\u6574\u6570\u95f4\u7684\u77ed\u7ebf\uff08-\uff09\u6307\u5b9a\u4e00\u4e2a\u6574\u6570\u8303\u56f4\u3002\u8b6c\u5982\uff0c1-4 \u610f\u5473\u7740\u6574\u6570 1\u30012\u30013\u30014\u3002<\/p>\n\n\n\n<p>\u7528\u9017\u53f7\uff08,\uff09\u9694\u5f00\u7684\u4e00\u7cfb\u5217\u503c\u6307\u5b9a\u4e00\u4e2a\u5217\u8868\u3002\u8b6c\u5982\uff0c3, 4, 6, 8 \u6807\u660e\u8fd9\u56db\u4e2a\u6307\u5b9a\u7684\u6574\u6570\u3002<\/p>\n\n\n\n<p>\u6b63\u659c\u7ebf\uff08\/\uff09\u53ef\u4ee5\u7528\u6765\u6307\u5b9a\u95f4\u9694\u9891\u7387\u3002\u5728\u8303\u56f4\u540e\u52a0\u4e0a \/&lt;integer&gt; \u610f\u5473\u7740\u5728\u8303\u56f4\u5185\u53ef\u4ee5\u8df3\u8fc7 integer\u3002\u8b6c\u5982\uff0c0-59\/2 \u53ef\u4ee5\u7528\u6765\u5728\u5206\u949f\u5b57\u6bb5\u5b9a\u4e49\u6bcf\u4e24\u5206\u949f\u3002\u95f4\u9694\u9891\u7387\u503c\u8fd8\u53ef\u4ee5\u548c\u661f\u53f7\u4e00\u8d77\u4f7f\u7528\u3002\u4f8b\u5982\uff0c*\/3 \u7684\u503c\u53ef\u4ee5\u7528\u5728\u6708\u4efd\u5b57\u6bb5\u4e2d\u8868\u793a\u6bcf\u4e09\u4e2a\u6708\u8fd0\u884c\u4e00\u6b21\u4efb\u52a1\u3002<\/p>\n\n\n\n<p>\u5f00\u5934\u4e3a\u4e95\u53f7\uff08#\uff09\u7684\u884c\u662f\u6ce8\u91ca\uff0c\u4e0d\u4f1a\u88ab\u5904\u7406\u3002<\/p>\n\n\n\n<p>\u5982\u4f60\u5728 \/etc\/crontab \u6587\u4ef6\u4e2d\u6240\u89c1\uff0c\u5b83\u4f7f\u7528 run-parts \u811a\u672c\u6765\u6267\u884c \/etc\/cron.hourly\u3001\/etc\/cron.daily\u3001\/etc\/cron.weekly \u548c \/etc\/cron.monthly \u76ee\u5f55\u4e2d\u7684\u811a\u672c\uff0c\u8fd9\u4e9b\u811a\u672c\u88ab\u76f8\u5e94\u5730\u6bcf\u5c0f\u65f6\u3001\u6bcf\u65e5\u3001\u6bcf\u5468\u3001\u6216\u6bcf\u6708\u6267\u884c\u3002\u8fd9\u4e9b\u76ee\u5f55\u4e2d\u7684\u6587\u4ef6\u5e94\u8be5\u662f shell \u811a\u672c\u3002\u5982\u679c\u67d0 cron \u4efb\u52a1\u9700\u8981\u6839\u636e\u8c03\u5ea6\u6765\u6267\u884c\uff0c\u800c\u4e0d\u662f\u6bcf\u5c0f\u65f6\u3001\u6bcf\u65e5\u3001\u6bcf\u5468\u3001\u6216\u6bcf\u6708\u5730\u6267\u884c\uff0c\u5b83\u53ef\u4ee5\u88ab\u6dfb\u52a0\u5230 \/etc\/cron.d \u76ee\u5f55\u4e2d\u3002\u8be5\u76ee\u5f55\u4e2d\u7684\u6240\u6709\u6587\u4ef6\u4f7f\u7528\u548c \/etc\/crontab \u4e2d\u4e00\u6837\u7684\u8bed\u6cd5\u3002\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># record the memory usage of the system every monday at 3:30AM in the file \/tmp\/meminfo\n30 3 * * mon cat \/proc\/meminfo &gt;&gt; \/tmp\/meminfo\n# run custom script the first day of every month at 4:10AM\n10 4 1 * * \/root\/scripts\/backup.sh\n<\/code><\/pre>\n\n\n\n<p>\u6839\u7528\u6237\u4ee5\u5916\u7684\u7528\u6237\u53ef\u4ee5\u4f7f\u7528 crontab \u5de5\u5177\u6765\u914d\u7f6e cron \u4efb\u52a1\u3002\u6240\u6709\u7528\u6237\u5b9a\u4e49\u7684 crontab \u90fd\u88ab\u4fdd\u5b58\u5728\/var\/spool\/cron \u76ee\u5f55\u4e2d\uff0c\u5e76\u4f7f\u7528\u521b\u5efa\u5b83\u4eec\u7684\u7528\u6237\u8eab\u4efd\u6765\u6267\u884c\u3002\u8981\u4ee5\u67d0\u7528\u6237\u8eab\u4efd\u521b\u5efa\u4e00\u4e2a crontab \u9879\u76ee\uff0c\u767b\u5f55\u4e3a\u8be5\u7528\u6237\uff0c\u7136\u540e\u952e\u5165 crontab -e \u547d\u4ee4\uff0c\u8be5\u6587\u4ef6\u4f7f\u7528\u7684\u683c\u5f0f\u548c \/etc\/crontab \u76f8\u540c\u3002\u5f53\u5bf9 crontab \u6240\u505a\u7684\u6539\u53d8\u88ab\u4fdd\u5b58\u540e\uff0c\u8be5 crontab \u6587\u4ef6\u5c31\u4f1a\u6839\u636e\u8be5\u7528\u6237\u540d\u88ab\u4fdd\u5b58\uff0c\u5e76\u5199\u5165\u6587\u4ef6 \/var\/spool\/cron\/username \u4e2d\u3002cron \u5b88\u62a4\u8fdb\u7a0b\u6bcf\u5206\u949f\u90fd\u68c0\u67e5 \/etc\/crontab \u6587\u4ef6\u3001etc\/cron.d\/ \u76ee\u5f55\u3001\u4ee5\u53ca \/var\/spool\/cron \u76ee\u5f55\u4e2d\u7684\u6539\u53d8\u3002\u5982\u679c\u53d1\u73b0\u4e86\u6539\u53d8\uff0c\u5b83\u4eec\u5c31\u4f1a\u88ab\u8f7d\u5165\u5185\u5b58\u3002\u8fd9\u6837\uff0c\u5f53\u67d0\u4e2a crontab \u6587\u4ef6\u6539\u53d8\u540e\u5c31\u4e0d\u5fc5\u91cd\u65b0\u542f\u52a8\u5b88\u62a4\u8fdb\u7a0b\u4e86\u3002<\/p>\n\n\n\n<p>\/etc\/cron.allow \u548c \/etc\/cron.deny \u6587\u4ef6\u88ab\u7528\u6765\u9650\u5236\u5bf9 cron \u7684\u4f7f\u7528\u3002\u8fd9\u4e24\u4e2a\u4f7f\u7528\u63a7\u5236\u6587\u4ef6\u7684\u683c\u5f0f\u90fd\u662f\u6bcf\u884c\u4e00\u4e2a\u7528\u6237\u3002\u4e24\u4e2a\u6587\u4ef6\u90fd\u4e0d\u5141\u8bb8\u7a7a\u683c\u3002\u5982\u679c\u4f7f\u7528\u63a7\u5236\u6587\u4ef6\u88ab\u4fee\u6539\u4e86\uff0ccron \u5b88\u62a4\u8fdb\u7a0b\uff08crond\uff09\u4e0d\u5fc5\u88ab\u91cd\u542f\u3002\u4f7f\u7528\u63a7\u5236\u6587\u4ef6\u5728\u6bcf\u6b21\u7528\u6237\u6dfb\u52a0\u6216\u5220\u9664\u4e00\u9879 cron \u4efb\u52a1\u65f6\u90fd\u4f1a\u88ab\u8bfb\u53d6\u3002\u65e0\u8bba\u4f7f\u7528\u63a7\u5236\u6587\u4ef6\u4e2d\u7684\u89c4\u5b9a\u5982\u4f55\uff0c\u6839\u7528\u6237\u90fd\u603b\u662f\u53ef\u4ee5\u4f7f\u7528 cron\u3002\u5982\u679c cron.allow \u6587\u4ef6\u5b58\u5728\uff0c\u53ea\u6709\u5176\u4e2d\u5217\u51fa\u7684\u7528\u6237\u624d\u88ab\u5141\u8bb8\u4f7f\u7528 cron\uff0c\u5e76\u4e14 cron.deny \u6587\u4ef6\u4f1a\u88ab\u5ffd\u7565\u3002\u5982\u679c cron.allow \u6587\u4ef6\u4e0d\u5b58\u5728\uff0c\u6240\u6709\u5728 cron.deny \u4e2d\u5217\u51fa\u7684\u7528\u6237\u90fd\u88ab\u7981\u6b62\u4f7f\u7528 cron\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5e38\u7528\u547d\u4ee4 \u76f4\u63a5\u7528crontab\u547d\u4ee4\u7f16\u8f91 cron\u670d\u52a1\u63d0\u4f9bcrontab\u547d\u4ee4\u6765\u8bbe\u5b9acron\u670d\u52a1\u7684\uff0c\u4ee5\u4e0b\u662f\u8fd9\u4e2a\u547d\u4ee4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[23],"class_list":["post-70","post","type-post","status-publish","format-standard","hentry","category-linux","tag-linux"],"_links":{"self":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/70","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=70"}],"version-history":[{"count":1,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions"}],"predecessor-version":[{"id":71,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=\/wp\/v2\/posts\/70\/revisions\/71"}],"wp:attachment":[{"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=70"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=70"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.handytoo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=70"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}