{"id":507,"date":"2016-05-25T17:29:58","date_gmt":"2016-05-25T17:29:58","guid":{"rendered":"http:\/\/2d6cc4b2d139a53512fb8cbb3086ae2e"},"modified":"2019-01-07T09:37:02","modified_gmt":"2019-01-07T01:37:02","slug":"crontab-cron-expressions","status":"publish","type":"post","link":"https:\/\/www.xiaobo.li\/notes\/archives\/507","title":{"rendered":"Crontab \/ Cron Expressions"},"content":{"rendered":"<p>cron\u8868\u8fbe\u5f0f\u548cLinux\u4e0b\u7684\u5f88\u7c7b\u4f3c\uff0c\u6bd4\u5982<span style=\"color: #000000;\">\u00a0\"\/5 * * ? * * *\" \u00a0<\/span>\u8fd9\u6837\u76847\u4f4d\u8868\u8fbe\u5f0f\uff0c\u6700\u540e\u4e00\u4f4d<span style=\"color: #000000;\">\u5e74<\/span>\u975e\u5fc5\u9009\u3002<\/p>\n<p><span style=\"color: #000000;\">\u8868\u8fbe\u5f0f\u4ece\u5de6\u5230\u53f3\uff0c\u4f9d\u6b64\u662f\u79d2\u3001\u5206\u3001\u65f6\u3001\u6708\u7b2c\u51e0\u5929\u3001\u6708\u3001\u5468\u51e0\u3001\u5e74\u3002\u4e0b\u9762\u8868\u683c\u662f\u8981\u9075\u5b88\u7684\u89c4\u8303\uff1a<\/span><\/p>\n<table style=\"width: 100%;\" border=\"1\" cellspacing=\"2\" cellpadding=\"3\" align=\"left\">\n<thead>\n<tr>\n<th><strong>\u6bb5\u540d<\/strong><\/th>\n<th>\u5141\u8bb8\u7684\u503c<\/th>\n<th>\u5141\u8bb8\u7684\u7279\u6b8a\u5b57\u7b26<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Seconds<\/td>\n<td>0-59<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Minutes<\/td>\n<td>0-59<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Hours<\/td>\n<td>0-23<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Day of month<\/td>\n<td>1-31<\/td>\n<td>, - * ? \/ L W<\/td>\n<\/tr>\n<tr>\n<td>Month<\/td>\n<td>1-12 or JAN-DEC<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Day of week<\/td>\n<td>1-7 or SUN-SAT<\/td>\n<td>, - * ? \/ L #<\/td>\n<\/tr>\n<tr>\n<td>Year<\/td>\n<td>\u7a7a, 1970-2099<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<table style=\"width: 100%;\" border=\"1\" cellspacing=\"3\" cellpadding=\"3\" align=\"left\">\n<tbody>\n<tr>\n<td>\u7279\u6b8a\u5b57\u7b26<\/td>\n<td>\u89e3\u91ca<\/td>\n<\/tr>\n<tr>\n<td>,<\/td>\n<td>\u6216\u7684\u610f\u601d\u3002\u4f8b\uff1a\u5206\u949f\u4f4d 5,10 \u00a0\u5373\u7b2c5\u5206\u949f\u621610\u5206\u90fd\u89e6\u53d1\u3002<\/td>\n<\/tr>\n<tr>\n<td>\/<\/td>\n<td>a\/b\u3002 a\uff1a\u4ee3\u8868\u8d77\u59cb\u65f6\u95f4\uff0cb\u9891\u7387\u65f6\u95f4\u3002 \u4f8b\uff1b \u5206\u949f\u4f4d \u00a03\/5\uff0c \u00a0\u4ece\u7b2c\u4e09\u5206\u949f\u5f00\u59cb\uff0c\u6bcf5\u5206\u949f\u6267\u884c\u4e00\u6b21\u3002<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>\u9891\u7387\u3002 \u5373\u6bcf\u4e00\u6b21\u6ce2\u52a8\u3002 \u00a0 \u00a0\u4f8b\uff1b\u5206\u949f\u4f4d * \u00a0\u5373\u8868\u793a\u6bcf\u5206\u949f<\/td>\n<\/tr>\n<tr>\n<td>-<\/td>\n<td>\u533a\u95f4\u3002 \u00a0\u4f8b\uff1a \u5206\u949f\u4f4d \u00a0 5-10 \u53735\u523010\u5206\u671f\u95f4\u3002<\/td>\n<\/tr>\n<tr>\n<td>?<\/td>\n<td>\u4efb\u610f\u503c\u00a0\u3002 \u00a0 \u5373\u6bcf\u4e00\u6b21\u6ce2\u52a8\u3002\u53ea\u80fd\u7528\u5728DayofMonth\u548cDayofWeek\uff0c\u4e8c\u8005\u51b2\u7a81\u3002\u6307\u5b9a\u4e00\u4e2a\u53e6\u4e00\u4e2a\u4e00\u4e2a\u8981\u7528?<\/td>\n<\/tr>\n<tr>\n<td>L<\/td>\n<td>\u8868\u793a\u6700\u540e\u3002 \u53ea\u80fd\u7528\u5728DayofMonth\u548cDayofWeek\uff0c4L\u5373\u6700\u540e\u4e00\u4e2a\u661f\u671f\u4e09<\/td>\n<\/tr>\n<tr>\n<td>W<\/td>\n<td>\u5de5\u4f5c\u65e5\u3002 \u00a0\u8868\u793a\u6700\u540e\u3002 \u53ea\u80fd\u7528\u5728DayofWeek<\/td>\n<\/tr>\n<tr>\n<td>#<\/td>\n<td>4#2\u3002 \u53ea\u80fd\u7528DayofMonth\u3002 \u67d0\u6708\u7684\u7b2c\u4e8c\u4e2a\u661f\u671f\u4e09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<h4>\u5b9e\u4f8b\u4ecb\u7ecd<\/h4>\n<p>\u201d0 0 10,14,16 * * ?\" \u00a0 \u00a0\u6bcf\u592910\u70b9\uff0c14\u70b9\uff0c16\u70b9 \u89e6\u53d1\u3002<\/p>\n<p>\"0 0\/5 14,18 * * ?\" \u00a0 \u00a0\u6bcf\u592914\u70b9\u621618\u70b9\u4e2d\uff0c\u6bcf5\u5206\u949f\u89e6\u53d1 \u3002<\/p>\n<p>\"0 4\/15 14-18 * * ?\" \u00a0 \u00a0 \u00a0 \u6bcf\u592914\u70b9\u523018\u70b9\u671f\u95f4, \u00a0\u4ece\u7b2c\u56db\u5206\u949f\u89e6\u53d1\uff0c\u6bcf15\u5206\u949f\u4e00\u6b21\u3002<\/p>\n<p>\"0 15 10 ? * 6L\"\u00a0 \u00a0 \u00a0 \u00a0\u00a0\u6bcf\u6708\u7684\u6700\u540e\u4e00\u4e2a\u661f\u671f\u4e94\u4e0a\u534810:15\u89e6\u53d1\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>\u4e00\u4e9b\u5b8c\u6574\u7684Cron- Expressions\u4f8b\u5b50\uff1a<\/p>\n<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"168\">\n<p align=\"center\"><strong>\u8868\u8fbe\u5f0f<\/strong><\/p>\n<\/td>\n<td valign=\"top\" width=\"420\">\n<p align=\"center\"><strong>\u610f\u601d<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 0 12 * * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u592912:00\u6267\u884c\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 ? * *<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u592910:15\u6267\u884c\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 * * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u592910:15\u6267\u884c\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 * * ? *<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u592910:15\u6267\u884c\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 * * ? 2005<\/td>\n<td valign=\"top\" width=\"420\">2005\u5e74\u7684\u6bcf\u592910:15\u6267\u884c\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 * 14 * * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u5929\u4ece14:00\u523014:59\u6bcf\u96941\u5206\u949f\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 0\/5 14 * * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u5929\u4ece14:00\u523014:59\u6bcf\u4e2a5\u5206\u949f\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 0\/5 14,18 * * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u5929\u4ece14:00\u523014:59\u548c18:00\u523018:59\u6bcf\u96945\u5206\u949f\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 0-5 14 * * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u5929\u4ece14:00\u523014:05\u6bcf\u96941\u5206\u949f\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 10,44 14 ? 3 WED<\/td>\n<td valign=\"top\" width=\"420\">3\u6708\u7684\u6bcf\u4e2a\u661f\u671f3\u768414:10\u548c14:44\u5206\u522b\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 15 * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u6708\u7684\u7b2c15\u65e510:15\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 L * ?<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u6708\u6700\u540e\u4e00\u5929\u768410:15\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 ? * 6L<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u6708\u7684\u6700\u540e\u4e00\u4e2a\u661f\u671f5\u768410:15\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 ? * 2002-2005<\/td>\n<td valign=\"top\" width=\"420\">2002\u30012003\u30012004\u30012005\u5e74\u7684\u6bcf\u4e2a\u6708\u7684\u6700\u540e\u4e00\u4e2a\u661f\u671f5\u768410:15\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"168\">0 15 10 ? * 6#3<\/td>\n<td valign=\"top\" width=\"420\">\u6bcf\u6708\u7684\u7b2c3\u4e2a\u661f\u671f5\u768410:15\u6267\u884c\u4e00\u6b21\u89e6\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u00a0*\/5 * * * *<\/td>\n<td>\u6bcf\u4e94\u5206\u949f<\/td>\n<\/tr>\n<tr>\n<td>\u00a00 * * * *<\/td>\n<td>\u6bcf\u5c0f\u65f6<\/td>\n<\/tr>\n<tr>\n<td>\u00a00 0 * * *<\/td>\n<td>\u6bcf\u5929<\/td>\n<\/tr>\n<tr>\n<td>\u00a00 0 * * 0<\/td>\n<td>\u00a0\u6bcf\u5468<\/td>\n<\/tr>\n<tr>\n<td>\u00a00 0 1 * *<\/td>\n<td>\u00a0\u6bcf\u6708<\/td>\n<\/tr>\n<tr>\n<td>\u00a00 0 1 1 *<\/td>\n<td>\u00a0\u6bcf\u5e74<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<p><b>linux\/unix:\u00a0 crontab <\/b><b>\u683c\u5f0f<\/b>:<\/p>\n<p>crontab\u6587\u4ef6\u4e2d\uff0c\u6bcf\u4e00\u884c\u90fd\u4ee3\u8868\u4e00\u9879\u4efb\u52a1\uff0c\u6bcf\u884c\u7684\u6bcf\u4e2a\u5b57\u6bb5\u4ee3\u8868\u4e00\u9879\u8bbe\u7f6e\uff0c\u5b83\u7684\u683c\u5f0f\u5171\u5206\u4e3a\u516d\u4e2a\u5b57\u6bb5\uff0c\u524d\u4e94\u6bb5\u662f\u65f6\u95f4\u8bbe\u5b9a\u6bb5\uff0c\u7b2c\u516d\u6bb5\u662f\u8981\u6267\u884c\u7684\u547d\u4ee4\u6bb5\uff0c\u683c\u5f0f\u5982\u4e0b\uff1a<br \/>\nminute\u00a0\u00a0 hour\u00a0\u00a0 day\u00a0\u00a0 month\u00a0\u00a0 week\u00a0\u00a0 command<\/p>\n<p><b>\u5176\u4e2d\uff1a<\/b><br \/>\nminute\uff1a \u8868\u793a\u5206\u949f\uff0c\u53ef\u4ee5\u662f\u4ece0\u523059\u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\u3002<br \/>\nhour\uff1a\u8868\u793a\u5c0f\u65f6\uff0c\u53ef\u4ee5\u662f\u4ece0\u523023\u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\u3002<br \/>\nday\uff1a\u8868\u793a\u65e5\u671f\uff0c\u53ef\u4ee5\u662f\u4ece1\u523031\u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\u3002<br \/>\nmonth\uff1a\u8868\u793a\u6708\u4efd\uff0c\u53ef\u4ee5\u662f\u4ece1\u523012\u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\u3002<br \/>\nweek\uff1a\u8868\u793a\u661f\u671f\u51e0\uff0c\u53ef\u4ee5\u662f\u4ece0\u52307\u4e4b\u95f4\u7684\u4efb\u4f55\u6574\u6570\uff0c\u8fd9\u91cc\u76840\u62167\u4ee3\u8868\u661f\u671f\u65e5\u3002<\/p>\n<p>command\uff1a\u8981\u6267\u884c\u7684\u547d\u4ee4\uff0c\u53ef\u4ee5\u662f\u7cfb\u7edf\u547d\u4ee4\uff0c\u4e5f\u53ef\u4ee5\u662f\u81ea\u5df1\u7f16\u5199\u7684\u811a\u672c\u6587\u4ef6\u3002<\/p>\n<div class=\"table-box\">\n<table>\n<thead>\n<tr>\n<th>\u4ee3\u8868\u610f\u4e49<\/th>\n<th>\u5206\u949f<\/th>\n<th>\u5c0f\u65f6<\/th>\n<th>\u65e5\u671f<\/th>\n<th>\u6708\u4efd<\/th>\n<th>\u5468<\/th>\n<th>\u547d\u4ee4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u6570\u5b57\u8303\u56f4<\/td>\n<td>0~59<\/td>\n<td>0~23<\/td>\n<td>1~31<\/td>\n<td>1~12<\/td>\n<td>0~7<\/td>\n<td>\u9700\u8981\u6267\u884c\u7684\u547d\u4ee4<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>&nbsp;<\/p>\n<p><b>\u7279\u6b8a\u5b57\u7b26\uff1a<\/b><br \/>\n\u661f\u53f7\uff08*\uff09\uff1a\u4ee3\u8868\u6240\u6709\u53ef\u80fd\u7684\u503c\uff0c\u4f8b\u5982month\u5b57\u6bb5\u5982\u679c\u662f\u661f\u53f7\uff0c\u5219\u8868\u793a\u5728\u6ee1\u8db3\u5176\u5b83\u5b57\u6bb5\u7684\u5236\u7ea6\u6761\u4ef6\u540e\u6bcf\u6708\u90fd\u6267\u884c\u8be5\u547d\u4ee4\u64cd\u4f5c\u3002<br \/>\n\u9017\u53f7\uff08,\uff09\uff1a\u53ef\u4ee5\u7528\u9017\u53f7\u9694\u5f00\u7684\u503c\u6307\u5b9a\u4e00\u4e2a\u5217\u8868\u8303\u56f4\uff0c\u4f8b\u5982\uff0c\u201c1,2,5,7,8,9\u201d<br \/>\n\u4e2d\u6760\uff08-\uff09\uff1a\u53ef\u4ee5\u7528\u6574\u6570\u4e4b\u95f4\u7684\u4e2d\u6760\u8868\u793a\u4e00\u4e2a\u6574\u6570\u8303\u56f4\uff0c\u4f8b\u5982\u201c2-6\u201d\u8868\u793a\u201c2,3,4,5,6\u201d<br \/>\n\u6b63\u659c\u7ebf\uff08\/\uff09\uff1a\u53ef\u4ee5\u7528\u6b63\u659c\u7ebf\u6307\u5b9a\u65f6\u95f4\u7684\u95f4\u9694\u9891\u7387\uff0c\u4f8b\u5982\u201c0-23\/2\u201d\u8868\u793a\u6bcf\u4e24\u5c0f\u65f6\u6267\u884c\u4e00\u6b21\u3002\u540c\u65f6\u6b63\u659c\u7ebf\u53ef\u4ee5\u548c\u661f\u53f7\u4e00\u8d77\u4f7f\u7528\uff0c\u4f8b\u5982*\/10\uff0c\u5982\u679c\u7528\u5728minute\u5b57\u6bb5\uff0c\u8868\u793a\u6bcf\u5341\u5206\u949f\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p>SHELL=\/bin\/bash<br \/>\nPATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin<br \/>\nMAILTO=root<br \/>\nHOME=\/<\/p>\n<p># For details see man 4 crontabs<\/p>\n<p># Example of job definition:<br \/>\n# .---------------- minute (0 - 59)<br \/>\n# | .------------- hour (0 - 23)<br \/>\n# | | .---------- day of month (1 - 31)<br \/>\n# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...<br \/>\n# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat<br \/>\n# | | | | |<br \/>\n# * * * * * user-name command to be executed<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-1488 size-full\" src=\"https:\/\/www.xiaobo.li\/notes\/wp-content\/uploads\/2016\/05\/722724-20160817105840890-421233819.png\" alt=\"\" width=\"420\" height=\"200\" srcset=\"https:\/\/www.xiaobo.li\/notes\/wp-content\/uploads\/2016\/05\/722724-20160817105840890-421233819.png 420w, https:\/\/www.xiaobo.li\/notes\/wp-content\/uploads\/2016\/05\/722724-20160817105840890-421233819-300x143.png 300w\" sizes=\"auto, (max-width: 420px) 100vw, 420px\" \/><\/p>\n<p><span style=\"color: #ff0000;\"> \u9664\u4e86\u6570\u5b57\u8fd8\u6709\u51e0\u4e2a\u4e2a\u7279\u6b8a\u7684\u7b26\u53f7\u5c31\u662f\"*\"\u3001\"\/\"\u548c\"-\"\u3001\",\"\uff0c*\u4ee3\u8868\u6240\u6709\u7684\u53d6\u503c\u8303\u56f4\u5185\u7684\u6570\u5b57\uff0c\"\/\"\u4ee3\u8868\u6bcf\u7684\u610f\u601d,\"\/5\"\u8868\u793a\u6bcf5\u4e2a\u5355\u4f4d\uff0c\"-\"\u4ee3\u8868\u4ece\u67d0\u4e2a\u6570\u5b57\u5230\u67d0\u4e2a\u6570\u5b57,\",\"\u5206\u5f00\u51e0\u4e2a\u79bb\u6563\u7684\u6570\u5b57\u3002<\/span><\/p>\n<p>-l \u5728\u6807\u51c6\u8f93\u51fa\u4e0a\u663e\u793a\u5f53\u524d\u7684crontab\u3002<br \/>\n-r \u5220\u9664\u5f53\u524d\u7684crontab\u6587\u4ef6\u3002<br \/>\n-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><strong>\u4f8b\u5b50\uff1a\u00a0<\/strong><br \/>\n\u6bcf\u5929\u65e9\u4e0a6\u70b9<br \/>\n0 6 * * * echo \"Good morning.\" &gt;&gt; \/tmp\/test.txt<\/p>\n<p>\u6bcf\u4e24\u4e2a\u5c0f\u65f6<br \/>\n0 *\/2 * * * echo \"Have a break now.\" &gt;&gt; \/tmp\/test.txt<\/p>\n<p>\u665a\u4e0a11\u70b9\u5230\u65e9\u4e0a8\u70b9\u4e4b\u95f4\u6bcf\u4e24\u4e2a\u5c0f\u65f6\u548c\u65e9\u4e0a\u516b\u70b9<br \/>\n0 23-7\/2\uff0c8 * * * echo \"Have a good dream\" &gt;&gt; \/tmp\/test.txt<\/p>\n<p>\u6bcf\u4e2a\u6708\u76844\u53f7\u548c\u6bcf\u4e2a\u793c\u62dc\u7684\u793c\u62dc\u4e00\u5230\u793c\u62dc\u4e09\u7684\u65e9\u4e0a11\u70b9<br \/>\n0 11 4 * 1-3 command line<\/p>\n<p>1\u67081\u65e5\u65e9\u4e0a4\u70b9<br \/>\n0 4 1 1 * command line SHELL=\/bin\/bash PATH=\/sbin:\/bin:\/usr\/sbin:\/usr\/bin MAILTO=root<br \/>\n\/\/\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=\/<\/p>\n<p>\u6bcf\u5c0f\u65f6\u6267\u884c\/etc\/cron.hourly\u5185\u7684\u811a\u672c<br \/>\n01 * * * * root run-parts \/etc\/cron.hourly<\/p>\n<p>\u6bcf\u5929\u6267\u884c\/etc\/cron.daily\u5185\u7684\u811a\u672c<br \/>\n02 4 * * * root run-parts \/etc\/cron.daily<\/p>\n<p>\u6bcf\u661f\u671f\u6267\u884c\/etc\/cron.weekly\u5185\u7684\u811a\u672c<br \/>\n22 4 * * 0 root run-parts \/etc\/cron.weekly<\/p>\n<p>\u6bcf\u6708\u53bb\u6267\u884c\/etc\/cron.monthly\u5185\u7684\u811a\u672c<br \/>\n42 4 1 * * root run-parts \/etc\/cron.monthly<\/p>\n<p>\u6ce8\u610f: \"run-parts\"\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<\/p>\n<p>\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<br \/>\n5\uff0c15\uff0c25\uff0c35\uff0c45\uff0c55 16\uff0c17\uff0c18 * * * command<\/p>\n<p>\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 \/>\n00 15 * * 1\uff0c3\uff0c5 shutdown -r +5<\/p>\n<p>\u6bcf\u5c0f\u65f6\u768410\u5206\uff0c40\u5206\u6267\u884c\u7528\u6237\u76ee\u5f55\u4e0b\u7684innd\/bbslin\u8fd9\u4e2a\u6307\u4ee4\uff1a<br \/>\n10\uff0c40 * * * * innd\/bbslink<\/p>\n<p>\u6bcf\u5c0f\u65f6\u76841\u5206\u6267\u884c\u7528\u6237\u76ee\u5f55\u4e0b\u7684bin\/account\u8fd9\u4e2a\u6307\u4ee4\uff1a<br \/>\n1 * * * * bin\/account<\/p>\n<p>\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<br \/>\n20 3 * * * \uff08\/bin\/rm -f expire.ls logins.bad;bin\/expire$#@62;expire.1st\uff09<\/p>\n<p>\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<br \/>\n12,55 3 4-9 1,4 * \/bin\/rm -f expire.1st$#@62;$#@62;mm.txt<\/p>\n<p>&nbsp;<\/p>\n<p>1.\u6bcf\u5206\u949f\u5b9a\u65f6\u6267\u884c\u4e00\u6b21\u89c4\u5219\uff1a<br \/>\n\u6bcf1\u5206\u949f\u6267\u884c\uff1a *\/1 * * * *\u6216\u8005* * * * *<br \/>\n\u6bcf5\u5206\u949f\u6267\u884c\uff1a *\/5 * * * *<\/p>\n<p>2.\u6bcf\u5c0f\u65f6\u5b9a\u65f6\u6267\u884c\u4e00\u6b21\u89c4\u5219\uff1a<br \/>\n\u6bcf\u5c0f\u65f6\u6267\u884c\uff1a 0 * * * *\u6216\u80050 *\/1 * * *<br \/>\n\u6bcf\u5929\u4e0a\u53487\u70b9\u6267\u884c\uff1a0 7 * * *<br \/>\n\u6bcf\u5929\u4e0a\u53487\u70b910\u5206\u6267\u884c\uff1a10 7 * * *<\/p>\n<p>3.\u6bcf\u5929\u5b9a\u65f6\u6267\u884c\u4e00\u6b21\u89c4\u5219\uff1a<br \/>\n\u6bcf\u5929\u6267\u884c 0 0 * * *<\/p>\n<p>4.\u6bcf\u5468\u5b9a\u65f6\u6267\u884c\u4e00\u6b21\u89c4\u5219\uff1a<br \/>\n\u6bcf\u5468\u6267\u884c 0 0 * * 0<\/p>\n<p>5.\u6bcf\u6708\u5b9a\u65f6\u6267\u884c\u4e00\u6b21\u89c4\u5219\uff1a<br \/>\n\u6bcf\u6708\u6267\u884c 0 0 1 * *<\/p>\n<p>6.\u6bcf\u5e74\u5b9a\u65f6\u6267\u884c\u4e00\u6b21\u89c4\u5219\uff1a<br \/>\n\u6bcf\u5e74\u6267\u884c 0 0 1 1 *<\/p>\n<p>7.\u5176\u4ed6\u4f8b\u5b50<br \/>\n5 * * * * \u6307\u5b9a\u6bcf\u5c0f\u65f6\u7684\u7b2c5\u5206\u949f\u6267\u884c\u4e00\u6b21ls\u547d\u4ee4<br \/>\n30 5 * * * ls \u6307\u5b9a\u6bcf\u5929\u7684 5:30 \u6267\u884cls\u547d\u4ee4<br \/>\n30 7 8 * * ls \u6307\u5b9a\u6bcf\u67088\u53f7\u76847\uff1a30\u5206\u6267\u884cls\u547d\u4ee4<br \/>\n30 5 8 6 * ls \u6307\u5b9a\u6bcf\u5e74\u76846\u67088\u65e55\uff1a30\u6267\u884cls\u547d\u4ee4<br \/>\n30 6 * * 0 ls \u6307\u5b9a\u6bcf\u661f\u671f\u65e5\u76846:30\u6267\u884cls\u547d\u4ee4[\u6ce8\uff1a0\u8868\u793a\u661f\u671f\u5929\uff0c1\u8868\u793a\u661f\u671f1\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u4e5f\u53ef\u4ee5\u7528\u82f1\u6587\u6765\u8868\u793a\uff0csun\u8868\u793a\u661f\u671f\u5929\uff0cmon\u8868\u793a\u661f\u671f\u4e00\u7b49\u3002]<br \/>\n30 3 10,20 * * ls \u6bcf\u670810\u53f7\u53ca20\u53f7\u76843\uff1a30\u6267\u884cls\u547d\u4ee4[\u6ce8\uff1a\u201c\uff0c\u201d\u7528\u6765\u8fde\u63a5\u591a\u4e2a\u4e0d\u8fde\u7eed\u7684\u65f6\u6bb5]<br \/>\n25 8-11 * * * ls \u6bcf\u59298-11\u70b9\u7684\u7b2c25\u5206\u949f\u6267\u884cls\u547d\u4ee4[\u6ce8\uff1a\u201c-\u201d\u7528\u6765\u8fde\u63a5\u8fde\u7eed\u7684\u65f6\u6bb5]<br \/>\n*\/15 * * * * ls \u6bcf15\u5206\u949f\u6267\u884c\u4e00\u6b21ls\u547d\u4ee4 [\u5373\u6bcf\u4e2a\u5c0f\u65f6\u7684\u7b2c0 15 30 45 60\u5206\u949f\u6267\u884cls\u547d\u4ee4 ]<br \/>\n30 6 *\/10 * * ls \u6bcf\u4e2a\u6708\u4e2d\uff0c\u6bcf\u969410\u59296:30\u6267\u884c\u4e00\u6b21ls\u547d\u4ee4[\u5373\u6bcf\u6708\u76841\u300111\u300121\u300131\u65e5\u662f\u76846\uff1a30\u6267\u884c\u4e00\u6b21ls\u547d\u4ee4\u3002 ]<\/p>\n<h3 class=\"title-text\">crontab\u4e2d\u7684\u8f93\u51fa\u914d\u7f6e<\/h3>\n<div class=\"para\">crontab\u4e2d\u7ecf\u5e38\u914d\u7f6e<a href=\"http:\/\/baike.baidu.com\/view\/513191.htm\" target=\"_blank\" rel=\"noopener\">\u8fd0\u884c\u811a\u672c<\/a>\u8f93\u51fa\u4e3a\uff1a&gt;\/dev\/null 2&gt;&amp;1\uff0c\u6765\u907f\u514dcrontab\u8fd0\u884c\u4e2d\u6709\u5185\u5bb9\u8f93\u51fa\u3002<\/div>\n<div class=\"para\">shell\u547d\u4ee4\u7684\u7ed3\u679c\u53ef\u4ee5\u901a\u8fc7\u2018&gt; \u2019\u7684\u5f62\u5f0f\u6765\u5b9a\u4e49\u8f93\u51fa<\/div>\n<div class=\"para\">\/dev\/null \u4ee3\u8868\u7a7a\u8bbe\u5907\u6587\u4ef6<\/div>\n<div class=\"para\">&gt; \u4ee3\u8868\u91cd\u5b9a\u5411\u5230\u54ea\u91cc\uff0c\u4f8b\u5982\uff1aecho \"123\" &gt; \/home\/123.txt<\/div>\n<div class=\"para\">1 \u8868\u793astdout\u6807\u51c6\u8f93\u51fa\uff0c\u7cfb\u7edf\u9ed8\u8ba4\u503c\u662f1\uff0c\u6240\u4ee5\"&gt;\/dev\/null\"\u7b49\u540c\u4e8e\"1&gt;\/dev\/null\"<\/div>\n<div class=\"para\">2 \u8868\u793astderr\u6807\u51c6\u9519\u8bef<\/div>\n<div class=\"para\">&amp; \u8868\u793a\u7b49\u540c\u4e8e\u7684\u610f\u601d\uff0c2&gt;&amp;1\uff0c\u8868\u793a2\u7684\u8f93\u51fa\u91cd\u5b9a\u5411\u7b49\u540c\u4e8e1<\/div>\n<div class=\"para\">\u90a3\u4e48\u91cd\u5b9a\u5411\u8f93\u51fa\u8bed\u53e5\u7684\u542b\u4e49\uff1a<\/div>\n<div class=\"para\">1&gt;\/dev\/null \u9996\u5148\u8868\u793a\u6807\u51c6\u8f93\u51fa\u91cd\u5b9a\u5411\u5230\u7a7a\u8bbe\u5907\u6587\u4ef6\uff0c\u4e5f\u5c31\u662f\u4e0d\u8f93\u51fa\u4efb\u4f55\u4fe1\u606f\u5230\u7ec8\u7aef\uff0c\u4e0d\u663e\u793a\u4efb\u4f55\u4fe1\u606f\u3002<\/div>\n<div class=\"para\">2&gt;&amp;1 \u8868\u793a\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u91cd\u5b9a\u5411\u7b49\u540c\u4e8e\u6807\u51c6\u8f93\u51fa\uff0c\u56e0\u4e3a\u4e4b\u524d\u6807\u51c6\u8f93\u51fa\u5df2\u7ecf\u91cd\u5b9a\u5411\u5230\u4e86\u7a7a\u8bbe\u5907\u6587\u4ef6\uff0c\u6240\u4ee5\u6807\u51c6\u9519\u8bef\u8f93\u51fa\u4e5f\u91cd\u5b9a\u5411\u5230\u7a7a\u8bbe\u5907\u6587\u4ef6\u3002<\/div>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>cron\u8868\u8fbe\u5f0f\u548cLinux\u4e0b\u7684\u5f88\u7c7b\u4f3c\uff0c\u6bd4\u5982<span style=\"color:#000000;\">&nbsp;\"\/5 * * ? * * *\" &nbsp;<\/span>\u8fd9\u6837\u76847\u4f4d\u8868\u8fbe\u5f0f\uff0c\u6700\u540e\u4e00\u4f4d<span style=\"color:#000000;\">\u5e74<\/span>\u975e\u5fc5\u9009\u3002<\/p>\n<p><span style=\"color:#000000;\">\u8868\u8fbe\u5f0f\u4ece\u5de6\u5230\u53f3\uff0c\u4f9d\u6b64\u662f\u79d2\u3001\u5206\u3001\u65f6\u3001\u6708\u7b2c\u51e0\u5929\u3001\u6708\u3001\u5468\u51e0\u3001\u5e74\u3002\u4e0b\u9762\u8868\u683c\u662f\u8981\u9075\u5b88\u7684\u89c4\u8303\uff1a<\/span><\/p>\n<table style=\"width:100%;\" align=\"left\" border=\"1\" cellpadding=\"3\" cellspacing=\"2\">\n<thead>\n<tr>\n<th><strong>\u6bb5\u540d<\/strong><\/th>\n<th>\u5141\u8bb8\u7684\u503c<\/th>\n<th>\u5141\u8bb8\u7684\u7279\u6b8a\u5b57\u7b26<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Seconds<\/td>\n<td>0-59<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Minutes<\/td>\n<td>0-59<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Hours<\/td>\n<td>0-23<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Day of month<\/td>\n<td>1-31<\/td>\n<td>, - * ? \/ L W<\/td>\n<\/tr>\n<tr>\n<td>Month<\/td>\n<td>1-12 or JAN-DEC<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<tr>\n<td>Day of week<\/td>\n<td>1-7 or SUN-SAT<\/td>\n<td>, - * ? \/ L #<\/td>\n<\/tr>\n<tr>\n<td>Year<\/td>\n<td>\u7a7a, 1970-2099<\/td>\n<td>, - * \/<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;&nbsp; <\/p>\n<table style=\"width:100%;\" align=\"left\" height=\"172\" border=\"1\" cellpadding=\"3\" cellspacing=\"3\">\n<tbody>\n<tr>\n<td>\u7279\u6b8a\u5b57\u7b26<\/td>\n<td>\u89e3\u91ca<\/td>\n<\/tr>\n<tr>\n<td>,<\/td>\n<td>\u6216\u7684\u610f\u601d\u3002\u4f8b\uff1a\u5206\u949f\u4f4d 5,10 &nbsp;\u5373\u7b2c5\u5206\u949f\u621610\u5206\u90fd\u89e6\u53d1\u3002&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>\/<\/td>\n<td>a\/b\u3002 a\uff1a\u4ee3\u8868\u8d77\u59cb\u65f6\u95f4\uff0cb\u9891\u7387\u65f6\u95f4\u3002 \u4f8b\uff1b \u5206\u949f\u4f4d &nbsp;3\/5\uff0c &nbsp;\u4ece\u7b2c\u4e09\u5206\u949f\u5f00\u59cb\uff0c\u6bcf5\u5206\u949f\u6267\u884c\u4e00\u6b21\u3002<\/td>\n<\/tr>\n<tr>\n<td>*<\/td>\n<td>\u9891\u7387\u3002 \u5373\u6bcf\u4e00\u6b21\u6ce2\u52a8\u3002 &nbsp; &nbsp;\u4f8b\uff1b\u5206\u949f\u4f4d * &nbsp;\u5373\u8868\u793a\u6bcf\u5206\u949f&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>-<\/td>\n<td>\u533a\u95f4\u3002 &nbsp;\u4f8b\uff1a \u5206\u949f\u4f4d &nbsp; 5-10 \u53735\u523010\u5206\u671f\u95f4\u3002&nbsp;<\/td>\n<\/tr>\n<tr>\n<td>?<\/td>\n<td>\u4efb\u610f\u503c&nbsp;\u3002 &nbsp; \u5373\u6bcf\u4e00\u6b21\u6ce2\u52a8\u3002\u53ea\u80fd\u7528\u5728DayofMonth\u548cDayofWeek\uff0c\u4e8c\u8005\u51b2\u7a81\u3002\u6307\u5b9a\u4e00\u4e2a\u53e6\u4e00\u4e2a\u4e00\u4e2a\u8981\u7528?<\/td>\n<\/tr>\n<tr>\n<td>L<\/td>\n<td>\u8868\u793a\u6700\u540e\u3002 \u53ea\u80fd\u7528\u5728DayofMonth\u548cDayofWeek\uff0c4L\u5373\u6700\u540e\u4e00\u4e2a\u661f\u671f\u4e09<\/td>\n<\/tr>\n<tr>\n<td>W<\/td>\n<td>\u5de5\u4f5c\u65e5\u3002 &nbsp;\u8868\u793a\u6700\u540e\u3002 \u53ea\u80fd\u7528\u5728DayofWeek<\/td>\n<\/tr>\n<tr>\n<td>#<\/td>\n<td>4#2\u3002 \u53ea\u80fd\u7528DayofMonth\u3002 \u67d0\u6708\u7684\u7b2c\u4e8c\u4e2a\u661f\u671f\u4e09&nbsp;&nbsp;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp; <\/p>\n<h4>\u5b9e\u4f8b\u4ecb\u7ecd<\/h4>\n<p>\u201d0 0 10,14,16 * * ?\" &nbsp; &nbsp;\u6bcf\u592910\u70b9\uff0c14\u70b9\uff0c16\u70b9 \u89e6\u53d1\u3002<\/p>\n<p>\"0 0\/5 14,18 * * ?\" &nbsp; &nbsp;\u6bcf\u592914\u70b9\u621618\u70b9\u4e2d\uff0c\u6bcf5\u5206\u949f\u89e6\u53d1 \u3002<\/p>\n<p>\"0 4\/15 14-18 * * ?\" &nbsp; &nbsp; &nbsp; \u6bcf\u592914\u70b9\u523018\u70b9\u671f\u95f4, &nbsp;\u4ece\u7b2c\u56db\u5206\u949f\u89e6\u53d1\uff0c\u6bcf15\u5206\u949f\u4e00\u6b21\u3002<\/p>\n<p>\"0 15 10 ? * 6L\"&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;\u6bcf\u6708\u7684\u6700\u540e\u4e00\u4e2a\u661f\u671f\u4e94\u4e0a\u534810:15\u89e6\u53d1\u3002<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p> <a href=\"https:\/\/www.xiaobo.li\/notes\/archives\/507\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[283],"tags":[247,339],"class_list":["post-507","post","type-post","status-publish","format-standard","hentry","category-technologys","tag-cron","tag-crontab"],"_links":{"self":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/507","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/comments?post=507"}],"version-history":[{"count":0,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/posts\/507\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/media?parent=507"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/categories?post=507"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xiaobo.li\/notes\/wp-json\/wp\/v2\/tags?post=507"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}