{"id":1350,"date":"2023-03-19T09:59:39","date_gmt":"2023-03-19T01:59:39","guid":{"rendered":"https:\/\/www.appblog.cn\/?p=1350"},"modified":"2023-04-29T09:03:29","modified_gmt":"2023-04-29T01:03:29","slug":"centos-7-utilize-crontab-to-schedule-task-execution","status":"publish","type":"post","link":"https:\/\/www.appblog.cn\/index.php\/2023\/03\/19\/centos-7-utilize-crontab-to-schedule-task-execution\/","title":{"rendered":"CentOS 7 \u5229\u7528crontab\u5b9a\u65f6\u6267\u884c\u4efb\u52a1"},"content":{"rendered":"<p>cron\u670d\u52a1\u662fLinux\u7684\u5185\u7f6e\u670d\u52a1\uff0c\u4f46\u5b83\u4e0d\u4f1a\u5f00\u673a\u81ea\u52a8\u542f\u52a8\u3002\u5728Centos 7\u4e0b\u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u548c\u505c\u6b62\u670d\u52a1\uff1a<\/p>\n<pre><code># systemctl start crond\n# systemctl stop crond\n# systemctl restart crond\n# systemctl reload crond\n# systemctl status crond\n# systemctl enable crond<\/code><\/pre>\n<p><!-- more --><\/p>\n<p>\u4ee5\u4e0a1-5\u884c\u5206\u522b\u4e3a\u542f\u52a8\u3001\u505c\u6b62\u3001\u91cd\u542f\u670d\u52a1\uff0c\u91cd\u65b0\u52a0\u8f7d\u914d\u7f6e\uff0c\u67e5\u770b\u670d\u52a1\u8fd0\u884c\u72b6\u6001\u4ee5\u53ca\u8bbe\u7f6e\u670d\u52a1\u81ea\u542f\u52a8\u3002<\/p>\n<ul>\n<li>\u67e5\u770b\u5f53\u524d\u7528\u6237\u7684crontab\uff1acrontab -l<\/li>\n<li>\u67e5\u770b\u6307\u5b9a\u7528\u6237\u7684crontab\uff1acrontab -l -u root<\/li>\n<li>\u7f16\u8f91crontab\uff1acrontab -e<\/li>\n<li>\u5220\u9664crontab\uff1acrontab -r<\/li>\n<\/ul>\n<h2>crontab\u57fa\u672c\u683c\u5f0f<\/h2>\n<pre><code>*   *   *   *   *   command\n\u5206  \u65f6  \u65e5  \u6708  \u5468  \u547d\u4ee4<\/code><\/pre>\n<ul>\n<li>\u7b2c1\u5217\u8868\u793a\u5206\u949f1\uff5e59 \u6bcf\u5206\u949f\u7528<em>\u6216\u8005 <\/em>\/1\u8868\u793a<\/li>\n<li>\u7b2c2\u5217\u8868\u793a\u5c0f\u65f61\uff5e23\uff080\u8868\u793a0\u70b9\uff09<\/li>\n<li>\u7b2c3\u5217\u8868\u793a\u65e5\u671f1\uff5e31<\/li>\n<li>\u7b2c4\u5217\u8868\u793a\u6708\u4efd1\uff5e12<\/li>\n<li>\u7b2c5\u5217\u6807\u8bc6\u53f7\u661f\u671f0\uff5e6\uff080\u8868\u793a\u661f\u671f\u5929\uff09<\/li>\n<li>\u7b2c6\u5217\u8981\u8fd0\u884c\u7684\u547d\u4ee4<\/li>\n<\/ul>\n<h2>crontab\u914d\u7f6e\u793a\u4f8b<\/h2>\n<pre><code># \u8868\u793a\u6bcf\u4e2a\u5c0f\u65f6\u7684\u7b2c\u4e94\u5206\u949f\u6267\u884c\u4e00\u6b21\u811a\u672c\n5 * * * * \/data\/www\/AppLog\/timing_tasks\/razor_hourly_archive.sh\n\n# \u8868\u793a\u6bcf\u5929\u76841\uff1a00\u6267\u884c\u4e00\u6b21\u811a\u672c\n0 1 * * * \/data\/www\/AppLog\/timing_tasks\/razor_daily_archive.sh\n\n# \u8868\u793a\u6bcf\u4e2a\u661f\u671f\u59290:30\u6267\u884c\u4e00\u6b21\u811a\u672c\n30 0 * * 0 \/data\/www\/AppLog\/timing_tasks\/razor_weekly_archive.sh\n\n# \u8868\u793a\u6bcf\u4e2a\u6708\u7b2c\u4e00\u59290:30\u6267\u884c\u4e00\u6b21\u811a\u672c\n30 0 1 * * \/data\/www\/AppLog\/timing_tasks\/razor_monthly_archive.sh\n\n# \u8868\u793a\u6bcf\u59291:30\u6267\u884c\u4e00\u6b21\u811a\u672c\n30 1 * * * \/data\/www\/AppLog\/timing_tasks\/razor_laterdata_archive.sh<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>cron\u670d\u52a1\u662fLinux\u7684\u5185\u7f6e\u670d\u52a1\uff0c\u4f46\u5b83\u4e0d\u4f1a\u5f00\u673a\u81ea\u52a8\u542f\u52a8\u3002\u5728Centos 7\u4e0b\u53ef\u4ee5\u7528\u4ee5\u4e0b\u547d\u4ee4\u542f\u52a8\u548c\u505c\u6b62\u670d\u52a1\uff1a  [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[168],"class_list":["post-1350","post","type-post","status-publish","format-standard","hentry","category-devops-base","tag-cron"],"_links":{"self":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1350","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1350"}],"version-history":[{"count":0,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/posts\/1350\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1350"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1350"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appblog.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1350"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}