{"id":595,"date":"2020-01-31T08:54:39","date_gmt":"2020-01-31T00:54:39","guid":{"rendered":"http:\/\/h2.wjxy.net.cn:8081\/?p=595"},"modified":"2023-10-04T06:32:59","modified_gmt":"2023-10-03T22:32:59","slug":"crontab-%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1","status":"publish","type":"post","link":"https:\/\/www.wjxy.net.cn\/?p=595","title":{"rendered":"crontab \u5b9a\u65f6\u4efb\u52a1"},"content":{"rendered":"\n<p>\u6bcf\u969430\u5206\u949froot\u6267\u884c\u4e00\u6b21updatedb\u547d\u4ee4\uff1a<\/p>\n\n\n\n<p><code>*\/30 * * * * root updatedb<\/code><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><code>00 *   * * *  <\/code>#\u6bcf\u5c0f\u65f6\u76840\u5206\u6267\u884c\u4e00\u6b21\n0 *\/3 * * * #\u6bcf\u96943\u5c0f\u65f6\u76840\u5206\u6267\u884c\u4e00\u6b21\u5199\u6cd5\n*\/60  * * * * #\u6bcf60\u5206\u949f\u5373\u6bcf\u5c0f\u65f6\u6267\u884c\u4e00\u6b21 *\/105 * * * * #\u6bcf105\u5206\u949f\u6267\u884c\u4e00\u6b21<code>#\u6bcf\u9694\u4e00\u5c0f\u65f6\u6267\u884c\u4e00\u6b21\n00 *\/1 * * *  #\u4e0e\u4e0a\u9762\u662f\u76f8\u540c\u7684\u4efb\u52a1<\/code>\n<strong><em>*  <\/em><\/strong><code><strong><em>*\/1 * * *  <\/em><\/strong><\/code><strong><em>#\u8fd9\u4e2a\u662f\u9519\u8bef\u7684\u793a\u8303\uff0c\u8fd9\u4e2a\u4f1a\u6bcf\u5206\u949f\u6267\u884c\u4e00\u6b21<\/em><\/strong>\n\u65e5\u5fd7\u53ef\u4ee5cat  \/var\/spool\/mail\/root\u67e5\u770b<\/pre>\n\n\n\n<ol><li>crontab \u5b9a\u65f6\u4efb\u52a1<br>\n\u901a\u8fc7crontab \u547d\u4ee4\uff0c\u6211\u4eec\u53ef\u4ee5\u5728\u56fa\u5b9a\u7684\u95f4\u9694\u65f6\u95f4\u6267\u884c\u6307\u5b9a\u7684\u7cfb\u7edf\u6307\u4ee4\u6216 shell script\u811a\u672c\u3002\u65f6\u95f4\u95f4\u9694\u7684\u5355\u4f4d\u53ef\u4ee5\u662f\u5206\u949f\u3001\u5c0f\u65f6\u3001\u65e5\u3001\u6708\u3001\u5468\u53ca\u4ee5\u4e0a\u7684\u4efb\u610f\u7ec4\u5408\u3002\u8fd9\u4e2a\u547d\u4ee4\u975e\u5e38\u9002\u5408\u5468\u671f\u6027\u7684\u65e5\u5fd7\u5206\u6790\u6216\u6570\u636e\u5907\u4efd\u7b49\u5de5\u4f5c\u3002<\/li><\/ol>\n\n\n\n<p> crontab \u5b9a\u65f6\u4efb\u52a1 <\/p>\n\n\n\n<p>\u7b2c1\u5217\u5206\u949f0\uff5e59<br>\n\u7b2c2\u5217\u5c0f\u65f60\uff5e23\uff080\u8868\u793a\u5b50\u591c\uff09<br>\n\u7b2c3\u5217\u65e51\uff5e31<br>\n\u7b2c4\u5217\u67081\uff5e12<br>\n\u7b2c5\u5217\u661f\u671f0\uff5e7\uff080\u548c7\u8868\u793a\u661f\u671f\u5929\uff09<br>\n\u7b2c6\u5217\u8981\u8fd0\u884c\u7684\u547d\u4ee4<br>\n19.4. \u5e38\u7528\u65b9\u6cd5<br>\n\u521b\u5efa\u4e00\u4e2a\u65b0\u7684crontab\u6587\u4ef6<br>\n\u5411cron\u8fdb\u7a0b\u63d0\u4ea4\u4e00\u4e2acrontab\u6587\u4ef6\u4e4b\u524d\uff0c\u9996\u5148\u8981\u8bbe\u7f6e\u73af\u5883\u53d8\u91cfEDITOR\u3002cron\u8fdb\u7a0b\u6839\u636e\u5b83\u6765\u786e\u5b9a\u4f7f\u7528\u54ea\u4e2a\u7f16\u8f91\u5668\u7f16\u8f91crontab\u6587\u4ef6\u30029 9 %\u7684UNIX\u548cLINUX\u7528\u6237\u90fd\u4f7f\u7528vi\uff0c\u5982\u679c\u4f60\u4e5f\u662f\u8fd9\u6837\uff0c\u90a3\u4e48\u4f60\u5c31\u7f16\u8f91$HOME\u76ee\u5f55\u4e0b\u7684. profile\u6587\u4ef6\uff0c\u5728\u5176\u4e2d\u52a0\u5165\u8fd9\u6837\u4e00\u884c:<\/p>\n\n\n\n<p>EDITOR=vi; export EDITOR<br>\n\u7136\u540e\u4fdd\u5b58\u5e76\u9000\u51fa\u3002\u4e0d\u59a8\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a cron\u7684\u6587\u4ef6\uff0c\u5176\u4e2d\u662f\u7528\u6237\u540d\uff0c\u4f8b\u5982\uff0c davecron\u3002\u5728\u8be5\u6587\u4ef6\u4e2d\u52a0\u5165\u5982\u4e0b\u7684\u5185\u5bb9\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">(put your own initials here)echo the date to the console every<\/h1>\n\n\n\n<h1 class=\"wp-block-heading\">15minutes between 6pm and 6am<\/h1>\n\n\n\n<p>0,15,30,45 18-06 * * * \/bin\/echo &#8216;date&#8217; &gt; \/dev\/console<br>\n\u4fdd\u5b58\u5e76\u9000\u51fa\u3002\u6ce8\u610f\u524d\u97625\u4e2a\u57df\u7528\u7a7a\u683c\u5206\u9694\u3002<\/p>\n\n\n\n<p>\u5728\u4e0a\u9762\u7684\u4f8b\u5b50\u4e2d\uff0c\u7cfb\u7edf\u5c06\u6bcf\u96941 5\u5206\u949f\u5411\u63a7\u5236\u53f0\u8f93\u51fa\u4e00\u6b21\u5f53\u524d\u65f6\u95f4\u3002\u5982\u679c\u7cfb\u7edf\u5d29\u6e83\u6216\u6302\u8d77\uff0c\u4ece\u6700\u540e\u6240\u663e\u793a\u7684\u65f6\u95f4\u5c31\u53ef\u4ee5\u4e00\u773c\u770b\u51fa\u7cfb\u7edf\u662f\u4ec0\u4e48\u65f6\u95f4\u505c\u6b62\u5de5\u4f5c\u7684\u3002\u5728\u6709\u4e9b\u7cfb\u7edf\u4e2d\uff0c\u7528tty1\u6765\u8868\u793a\u63a7\u5236\u53f0\uff0c\u53ef\u4ee5\u6839\u636e\u5b9e\u9645\u60c5\u51b5\u5bf9\u4e0a\u9762\u7684\u4f8b\u5b50\u8fdb\u884c\u76f8\u5e94\u7684\u4fee\u6539\u3002\u4e3a\u4e86\u63d0\u4ea4\u4f60\u521a\u521a\u521b\u5efa\u7684crontab\u6587\u4ef6\uff0c\u53ef\u4ee5\u628a\u8fd9\u4e2a\u65b0\u521b\u5efa\u7684\u6587\u4ef6\u4f5c\u4e3acron\u547d\u4ee4\u7684\u53c2\u6570:<\/p>\n\n\n\n<p>$ crontab davecron<br>\n\u73b0\u5728\u8be5\u6587\u4ef6\u5df2\u7ecf\u63d0\u4ea4\u7ed9cron\u8fdb\u7a0b\uff0c\u5b83\u5c06\u6bcf\u96941 5\u5206\u949f\u8fd0\u884c\u4e00\u6b21\u3002\u540c\u65f6\uff0c\u65b0\u521b\u5efa\u6587\u4ef6\u7684\u4e00\u4e2a\u526f\u672c\u5df2\u7ecf\u88ab\u653e\u5728\/var\/spool\/cron\u76ee\u5f55\u4e2d\uff0c\u6587\u4ef6\u540d\u5c31\u662f\u7528\u6237\u540d(\u5373dave)\u3002<\/p>\n\n\n\n<p>\u5217\u51facrontab\u6587\u4ef6<br>\n\u4f7f\u7528-l\u53c2\u6570\u5217\u51facrontab\u6587\u4ef6:<\/p>\n\n\n\n<p>$ crontab -l<br>\n0,15,30,45 18-06 * * * \/bin\/echo <code>date<\/code> &gt; dev\/tty1<br>\n\u53ef\u4ee5\u4f7f\u7528\u8fd9\u79cd\u65b9\u6cd5\u5728$HOME\u76ee\u5f55\u4e2d\u5bf9crontab\u6587\u4ef6\u505a\u4e00\u5907\u4efd:<\/p>\n\n\n\n<p>$ crontab -l &gt; $HOME\/mycron<br>\n\u8fd9\u6837\uff0c\u4e00\u65e6\u4e0d\u5c0f\u5fc3\u8bef\u5220\u4e86crontab\u6587\u4ef6\uff0c\u53ef\u4ee5\u7528\u4e0a\u4e00\u8282\u6240\u8bb2\u8ff0\u7684\u65b9\u6cd5\u8fc5\u901f\u6062\u590d\u3002<\/p>\n\n\n\n<p>\u7f16\u8f91crontab\u6587\u4ef6<br>\n\u5982\u679c\u5e0c\u671b\u6dfb\u52a0\u3001\u5220\u9664\u6216\u7f16\u8f91crontab\u6587\u4ef6\u4e2d\u7684\u6761\u76ee\uff0c\u800cEDITOR\u73af\u5883\u53d8\u91cf\u53c8\u8bbe\u7f6e\u4e3avi\uff0c\u90a3\u4e48\u5c31\u53ef\u4ee5\u7528vi\u6765\u7f16\u8f91crontab\u6587\u4ef6:<\/p>\n\n\n\n<p>$ crontab -e<br>\n\u53ef\u4ee5\u50cf\u4f7f\u7528vi\u7f16\u8f91\u5176\u4ed6\u4efb\u4f55\u6587\u4ef6\u90a3\u6837\u4fee\u6539crontab\u6587\u4ef6\u5e76\u9000\u51fa\u3002\u5982\u679c\u4fee\u6539\u4e86\u67d0\u4e9b\u6761\u76ee\u6216\u6dfb\u52a0\u4e86\u65b0\u7684\u6761\u76ee\uff0c\u90a3\u4e48\u5728\u4fdd\u5b58\u8be5\u6587\u4ef6\u65f6\uff0c cron\u4f1a\u5bf9\u5176\u8fdb\u884c\u5fc5\u8981\u7684\u5b8c\u6574\u6027\u68c0\u67e5\u3002\u5982\u679c\u5176\u4e2d\u7684\u67d0\u4e2a\u57df\u51fa\u73b0\u4e86\u8d85\u51fa\u5141\u8bb8\u8303\u56f4\u7684\u503c\uff0c\u5b83\u4f1a\u63d0\u793a\u4f60\u3002 \u6211\u4eec\u5728\u7f16\u8f91crontab\u6587\u4ef6\u65f6\uff0c\u6ca1\u51c6\u4f1a\u52a0\u5165\u65b0\u7684\u6761\u76ee\u3002\u4f8b\u5982\uff0c\u52a0\u5165\u4e0b\u9762\u7684\u4e00\u6761\uff1a<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">DT:delete core files,at 3.30am on 1,7,14,21,26,26 days of each month<\/h1>\n\n\n\n<p>30 3 1,7,14,21,26 * * \/bin\/find -name &#8216;core&#8217; -exec rm {} ;<br>\n\u4fdd\u5b58\u5e76\u9000\u51fa\u3002<\/p>\n\n\n\n<p>\u6ce8\u89e3<\/p>\n\n\n\n<p>\u6700\u597d\u5728crontab\u6587\u4ef6\u7684\u6bcf\u4e00\u4e2a\u6761\u76ee\u4e4b\u4e0a\u52a0\u5165\u4e00\u6761\u6ce8\u91ca\uff0c\u8fd9\u6837\u5c31\u53ef\u4ee5\u77e5\u9053\u5b83\u7684\u529f\u80fd\u3001\u8fd0\u884c\u65f6\u95f4\uff0c\u66f4\u4e3a\u91cd\u8981\u7684\u662f\uff0c\u77e5\u9053\u8fd9\u662f\u54ea\u4f4d\u7528\u6237\u7684\u5b9a\u65f6\u4f5c\u4e1a\u3002<\/p>\n\n\n\n<p>\u5220\u9664crontab\u6587\u4ef6<br>\n$crontab -r<br>\n19.5. \u4f7f\u7528\u5b9e\u4f8b<br>\n\u5b9e\u4f8b1\uff1a\u6bcf1\u5206\u949f\u6267\u884c\u4e00\u6b21myCommand<\/p>\n\n\n\n<ul><li>* * * * myCommand<br>\n\u5b9e\u4f8b2\uff1a\u6bcf\u5c0f\u65f6\u7684\u7b2c3\u548c\u7b2c15\u5206\u949f\u6267\u884c<br>\n3,15 * * * * myCommand<br>\n\u5b9e\u4f8b3\uff1a\u5728\u4e0a\u53488\u70b9\u523011\u70b9\u7684\u7b2c3\u548c\u7b2c15\u5206\u949f\u6267\u884c<br>\n3,15 8-11 * * * myCommand<br>\n\u5b9e\u4f8b4\uff1a\u6bcf\u9694\u4e24\u5929\u7684\u4e0a\u53488\u70b9\u523011\u70b9\u7684\u7b2c3\u548c\u7b2c15\u5206\u949f\u6267\u884c<br>\n3,15 8-11 *\/2  *  * myCommand<br>\n\u5b9e\u4f8b5\uff1a\u6bcf\u5468\u4e00\u4e0a\u53488\u70b9\u523011\u70b9\u7684\u7b2c3\u548c\u7b2c15\u5206\u949f\u6267\u884c<br>\n3,15 8-11 * * 1 myCommand<br>\n\u5b9e\u4f8b6\uff1a\u6bcf\u665a\u768421:30\u91cd\u542fsmb<br>\n30 21 * * * \/etc\/init.d\/smb restart<br>\n\u5b9e\u4f8b7\uff1a\u6bcf\u67081\u300110\u300122\u65e5\u76844 : 45\u91cd\u542fsmb<br>\n45 4 1,10,22 * * \/etc\/init.d\/smb restart<br>\n\u5b9e\u4f8b8\uff1a\u6bcf\u5468\u516d\u3001\u5468\u65e5\u76841 : 10\u91cd\u542fsmb<br>\n10 1 * * 6,0 \/etc\/init.d\/smb restart<br>\n\u5b9e\u4f8b9\uff1a\u6bcf\u592918 : 00\u81f323 : 00\u4e4b\u95f4\u6bcf\u969430\u5206\u949f\u91cd\u542fsmb<br>\n0,30 18-23 * * * \/etc\/init.d\/smb restart<br>\n\u5b9e\u4f8b10\uff1a\u6bcf\u661f\u671f\u516d\u7684\u665a\u4e0a11 : 00 pm\u91cd\u542fsmb<br>\n0 23 * * 6 \/etc\/init.d\/smb restart<br>\n\u5b9e\u4f8b11\uff1a\u6bcf\u4e00\u5c0f\u65f6\u91cd\u542fsmb<\/li><li>*\/1 * * * \/etc\/init.d\/smb restart<br>\n\u5b9e\u4f8b12\uff1a\u665a\u4e0a11\u70b9\u5230\u65e9\u4e0a7\u70b9\u4e4b\u95f4\uff0c\u6bcf\u9694\u4e00\u5c0f\u65f6\u91cd\u542fsmb<br>\n0 23-7 * * * \/etc\/init.d\/smb restart<br>\n19.6. \u4f7f\u7528\u6ce8\u610f\u4e8b\u9879<br>\n\u6ce8\u610f\u73af\u5883\u53d8\u91cf\u95ee\u9898<br>\n\u6709\u65f6\u6211\u4eec\u521b\u5efa\u4e86\u4e00\u4e2acrontab\uff0c\u4f46\u662f\u8fd9\u4e2a\u4efb\u52a1\u5374\u65e0\u6cd5\u81ea\u52a8\u6267\u884c\uff0c\u800c\u624b\u52a8\u6267\u884c\u8fd9\u4e2a\u4efb\u52a1\u5374\u6ca1\u6709\u95ee\u9898\uff0c\u8fd9\u79cd\u60c5\u51b5\u4e00\u822c\u662f\u7531\u4e8e\u5728crontab\u6587\u4ef6\u4e2d\u6ca1\u6709\u914d\u7f6e\u73af\u5883\u53d8\u91cf\u5f15\u8d77\u7684\u3002<\/li><\/ul>\n\n\n\n<p>\u5728crontab\u6587\u4ef6\u4e2d\u5b9a\u4e49\u591a\u4e2a\u8c03\u5ea6\u4efb\u52a1\u65f6\uff0c\u9700\u8981\u7279\u522b\u6ce8\u73af\u5883\u53d8\u91cf\u7684\u8bbe\u7f6e\uff0c\u56e0\u4e3a\u6211\u4eec\u624b\u52a8\u6267\u884c\u67d0\u4e2a\u4efb\u52a1\u65f6\uff0c\u662f\u5728\u5f53\u524dshell\u73af\u5883\u4e0b\u8fdb\u884c\u7684\uff0c\u7a0b\u5e8f\u5f53\u7136\u80fd\u627e\u5230\u73af\u5883\u53d8\u91cf\uff0c\u800c\u7cfb\u7edf\u81ea\u52a8\u6267\u884c\u4efb\u52a1\u8c03\u5ea6\u65f6\uff0c\u662f\u4e0d\u4f1a\u52a0\u8f7d\u4efb\u4f55\u73af\u5883\u53d8\u91cf\u7684\uff0c\u56e0\u6b64\uff0c\u5c31\u9700\u8981\u5728crontab\u6587\u4ef6\u4e2d\u6307\u5b9a\u4efb\u52a1\u8fd0\u884c\u6240\u9700\u7684\u6240\u6709\u73af\u5883\u53d8\u91cf\uff0c\u8fd9\u6837\uff0c\u7cfb\u7edf\u6267\u884c\u4efb\u52a1\u8c03\u5ea6\u65f6\u5c31\u6ca1\u6709\u95ee\u9898\u4e86\u3002<\/p>\n\n\n\n<p>\u4e0d\u8981\u5047\u5b9acron\u77e5\u9053\u6240\u9700\u8981\u7684\u7279\u6b8a\u73af\u5883\uff0c\u5b83\u5176\u5b9e\u5e76\u4e0d\u77e5\u9053\u3002\u6240\u4ee5\u4f60\u8981\u4fdd\u8bc1\u5728shelll\u811a\u672c\u4e2d\u63d0\u4f9b\u6240\u6709\u5fc5\u8981\u7684\u8def\u5f84\u548c\u73af\u5883\u53d8\u91cf\uff0c\u9664\u4e86\u4e00\u4e9b\u81ea\u52a8\u8bbe\u7f6e\u7684\u5168\u5c40\u53d8\u91cf\u3002\u6240\u4ee5\u6ce8\u610f\u5982\u4e0b3\u70b9\uff1a<\/p>\n\n\n\n<p>\u811a\u672c\u4e2d\u6d89\u53ca\u6587\u4ef6\u8def\u5f84\u65f6\u5199\u5168\u5c40\u8def\u5f84\uff1b<\/p>\n\n\n\n<p>\u811a\u672c\u6267\u884c\u8981\u7528\u5230java\u6216\u5176\u4ed6\u73af\u5883\u53d8\u91cf\u65f6\uff0c\u901a\u8fc7source\u547d\u4ee4\u5f15\u5165\u73af\u5883\u53d8\u91cf\uff0c\u5982:<\/p>\n\n\n\n<p>cat start_cbp.sh<br>\n!\/bin\/sh<br>\nsource \/etc\/profile<br>\nexport RUN_CONF=\/home\/d139\/conf\/platform\/cbp\/cbp_jboss.conf<br>\n\/usr\/local\/jboss-4.0.5\/bin\/run.sh -c mev &amp;<br>\n\u5f53\u624b\u52a8\u6267\u884c\u811a\u672cOK\uff0c\u4f46\u662fcrontab\u6b7b\u6d3b\u4e0d\u6267\u884c\u65f6,\u5f88\u53ef\u80fd\u662f\u73af\u5883\u53d8\u91cf\u60f9\u7684\u7978\uff0c\u53ef\u5c1d\u8bd5\u5728crontab\u4e2d\u76f4\u63a5\u5f15\u5165\u73af\u5883\u53d8\u91cf\u89e3\u51b3\u95ee\u9898\u3002\u5982:<\/p>\n\n\n\n<p>0 * * * * . \/etc\/profile;\/bin\/sh \/var\/www\/java\/audit_no_count\/bin\/restart_audit.sh<br>\n\u6ce8\u610f\u6e05\u7406\u7cfb\u7edf\u7528\u6237\u7684\u90ae\u4ef6\u65e5\u5fd7<br>\n\u6bcf\u6761\u4efb\u52a1\u8c03\u5ea6\u6267\u884c\u5b8c\u6bd5\uff0c\u7cfb\u7edf\u90fd\u4f1a\u5c06\u4efb\u52a1\u8f93\u51fa\u4fe1\u606f\u901a\u8fc7\u7535\u5b50\u90ae\u4ef6\u7684\u5f62\u5f0f\u53d1\u9001\u7ed9\u5f53\u524d\u7cfb\u7edf\u7528\u6237\uff0c\u8fd9\u6837\u65e5\u79ef\u6708\u7d2f\uff0c\u65e5\u5fd7\u4fe1\u606f\u4f1a\u975e\u5e38\u5927\uff0c\u53ef\u80fd\u4f1a\u5f71\u54cd\u7cfb\u7edf\u7684\u6b63\u5e38\u8fd0\u884c\uff0c\u56e0\u6b64\uff0c\u5c06\u6bcf\u6761\u4efb\u52a1\u8fdb\u884c\u91cd\u5b9a\u5411\u5904\u7406\u975e\u5e38\u91cd\u8981\u3002 \u4f8b\u5982\uff0c\u53ef\u4ee5\u5728crontab\u6587\u4ef6\u4e2d\u8bbe\u7f6e\u5982\u4e0b\u5f62\u5f0f\uff0c\u5ffd\u7565\u65e5\u5fd7\u8f93\u51fa:<\/p>\n\n\n\n<p>0 *\/3 * * * \/usr\/local\/apache2\/apachectl restart &gt;\/dev\/null 2&gt;&amp;1<br>\n\u201c\/dev\/null 2&gt;&amp;1\u201d\u8868\u793a\u5148\u5c06\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\/dev\/null\uff0c\u7136\u540e\u5c06\u6807\u51c6\u9519\u8bef\u91cd\u5b9a\u5411\u5230\u6807\u51c6\u8f93\u51fa\uff0c\u7531\u4e8e\u6807\u51c6\u8f93\u51fa\u5df2\u7ecf\u91cd\u5b9a\u5411\u5230\u4e86\/dev\/null\uff0c\u56e0\u6b64\u6807\u51c6\u9519\u8bef\u4e5f\u4f1a\u91cd\u5b9a\u5411\u5230\/dev\/null\uff0c\u8fd9\u6837\u65e5\u5fd7\u8f93\u51fa\u95ee\u9898\u5c31\u89e3\u51b3\u4e86\u3002<\/p>\n\n\n\n<p>\u7cfb\u7edf\u7ea7\u4efb\u52a1\u8c03\u5ea6\u4e0e\u7528\u6237\u7ea7\u4efb\u52a1\u8c03\u5ea6<br>\n\u7cfb\u7edf\u7ea7\u4efb\u52a1\u8c03\u5ea6\u4e3b\u8981\u5b8c\u6210\u7cfb\u7edf\u7684\u4e00\u4e9b\u7ef4\u62a4\u64cd\u4f5c\uff0c\u7528\u6237\u7ea7\u4efb\u52a1\u8c03\u5ea6\u4e3b\u8981\u5b8c\u6210\u7528\u6237\u81ea\u5b9a\u4e49\u7684\u4e00\u4e9b\u4efb\u52a1\uff0c\u53ef\u4ee5\u5c06\u7528\u6237\u7ea7\u4efb\u52a1\u8c03\u5ea6\u653e\u5230\u7cfb\u7edf\u7ea7\u4efb\u52a1\u8c03\u5ea6\u6765\u5b8c\u6210\uff08\u4e0d\u5efa\u8bae\u8fd9\u4e48\u505a\uff09\uff0c\u4f46\u662f\u53cd\u8fc7\u6765\u5374\u4e0d\u884c\uff0croot\u7528\u6237\u7684\u4efb\u52a1\u8c03\u5ea6\u64cd\u4f5c\u53ef\u4ee5\u901a\u8fc7\u201dcrontab \u2013uroot \u2013e\u201d\u6765\u8bbe\u7f6e\uff0c\u4e5f\u53ef\u4ee5\u5c06\u8c03\u5ea6\u4efb\u52a1\u76f4\u63a5\u5199\u5165\/etc\/crontab\u6587\u4ef6\uff0c\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u5982\u679c\u8981\u5b9a\u4e49\u4e00\u4e2a\u5b9a\u65f6\u91cd\u542f\u7cfb\u7edf\u7684\u4efb\u52a1\uff0c\u5c31\u5fc5\u987b\u5c06\u4efb\u52a1\u653e\u5230\/etc\/crontab\u6587\u4ef6\uff0c\u5373\u4f7f\u5728root\u7528\u6237\u4e0b\u521b\u5efa\u4e00\u4e2a\u5b9a\u65f6\u91cd\u542f\u7cfb\u7edf\u7684\u4efb\u52a1\u4e5f\u662f\u65e0\u6548\u7684\u3002<\/p>\n\n\n\n<p>\u5176\u4ed6\u6ce8\u610f\u4e8b\u9879<br>\n\u65b0\u521b\u5efa\u7684cron job\uff0c\u4e0d\u4f1a\u9a6c\u4e0a\u6267\u884c\uff0c\u81f3\u5c11\u8981\u8fc72\u5206\u949f\u624d\u6267\u884c\u3002\u5982\u679c\u91cd\u542fcron\u5219\u9a6c\u4e0a\u6267\u884c\u3002<\/p>\n\n\n\n<p>\u5f53crontab\u5931\u6548\u65f6\uff0c\u53ef\u4ee5\u5c1d\u8bd5\/etc\/init.d\/crond restart\u89e3\u51b3\u95ee\u9898\u3002\u6216\u8005\u67e5\u770b\u65e5\u5fd7\u770b\u67d0\u4e2ajob\u6709\u6ca1\u6709\u6267\u884c\/\u62a5\u9519tail -f \/var\/log\/cron\u3002<\/p>\n\n\n\n<p>\u5343\u4e07\u522b\u4e71\u8fd0\u884ccrontab -r\u3002\u5b83\u4eceCrontab\u76ee\u5f55\uff08\/var\/spool\/cron\uff09\u4e2d\u5220\u9664\u7528\u6237\u7684Crontab\u6587\u4ef6\u3002\u5220\u9664\u4e86\u8be5\u7528\u6237\u7684\u6240\u6709crontab\u90fd\u6ca1\u4e86\u3002<\/p>\n\n\n\n<p>\u5728crontab\u4e2d%\u662f\u6709\u7279\u6b8a\u542b\u4e49\u7684\uff0c\u8868\u793a\u6362\u884c\u7684\u610f\u601d\u3002\u5982\u679c\u8981\u7528\u7684\u8bdd\u5fc5\u987b\u8fdb\u884c\u8f6c\u4e49%\uff0c\u5982\u7ecf\u5e38\u7528\u7684date \u2018+%Y%m%d\u2019\u5728crontab\u91cc\u662f\u4e0d\u4f1a\u6267\u884c\u7684\uff0c\u5e94\u8be5\u6362\u6210date \u2018+%Y%m%d\u2019\u3002<\/p>\n\n\n\n<p>\u66f4\u65b0\u7cfb\u7edf\u65f6\u95f4\u65f6\u533a\u540e\u9700\u8981\u91cd\u542fcron,\u5728ubuntu\u4e2d\u670d\u52a1\u540d\u4e3acron:<\/p>\n\n\n\n<p>$service cron restart<br>\nubuntu\u4e0b\u542f\u52a8\u3001\u505c\u6b62\u4e0e\u91cd\u542fcron:<\/p>\n\n\n\n<p>$sudo \/etc\/init.d\/cron start<br>\n$sudo \/etc\/init.d\/cron stop<br>\n$sudo \/etc\/init.d\/cron restart<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6bcf\u969430\u5206\u949froot\u6267\u884c\u4e00\u6b21updatedb\u547d\u4ee4\uff1a *\/30 * * * * root updatedb 00 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/595"}],"collection":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=595"}],"version-history":[{"count":5,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/595\/revisions"}],"predecessor-version":[{"id":2905,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/595\/revisions\/2905"}],"wp:attachment":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=595"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=595"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=595"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}