\u521b\u5efa\u4e00\u4e2a cronjob<\/strong><\/div>\n\u8981\u521b\u5efa\u4e00\u4e2a cronjob\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 crontab \u547d\u4ee4\uff0c\u5e76\u6dfb\u52a0 -e \u9009\u9879\uff1a<\/p>\n
$ crontab -e \r\n<\/pre>\n\u8fd9\u5c06\u4f7f\u7528\u9ed8\u8ba4\u7684\u6587\u672c\u7f16\u8f91\u5668\u6253\u5f00 crontab\u3002\u5982\u9700\u6307\u5b9a\u6587\u672c\u7f16\u8f91\u5668\uff0c\u8bf7\u4f7f\u7528 EDITOR \u73af\u5883\u53d8\u91cf\uff1a<\/p>\n
$ EDITOR=nano crontab -e \r\n<\/pre>\nCron \u8bed\u6cd5<\/strong><\/div>\n\u5982\u9700\u8c03\u5ea6\u4e00\u4e2a cronjob\uff0c\u4f60\u9700\u8981\u63d0\u4f9b\u7ed9\u8ba1\u7b97\u673a\u4f60\u60f3\u8981\u6267\u884c\u7684\u547d\u4ee4\uff0c\u7136\u540e\u63d0\u4f9b\u4e00\u4e2a cron \u8868\u8fbe\u5f0f\u3002cron \u8868\u8fbe\u5f0f\u5728\u547d\u4ee4\u8c03\u5ea6\u65f6\u8fd0\u884c\uff1a<\/p>\n
\u5206\u949f(0 \u5230 59)<\/ol>\n\u5c0f\u65f6(0 \u5230 23, 0 \u4ee3\u8868\u5348\u591c\u6267\u884c)<\/ol>\n\u65e5\u671f(1 \u5230 31)<\/ol>\n\u6708\u4efd(1 \u5230 12)<\/ol>\n\u661f\u671f(0 \u5230 6, \u661f\u671f\u5929\u662f 0)<\/ol>\n\u661f\u53f7 (*) \u4ee3\u8868\u7684\u662f\u201c\u6bcf\u4e00\u4e2a\u201d\u3002\u4f8b\u5982\uff0c\u4e0b\u9762\u7684\u8868\u8fbe\u5f0f\u5728\u6bcf\u6708\u6bcf\u65e5\u6bcf\u5c0f\u65f6\u76840\u5206\u949f\u8fd0\u884c\u5907\u4efd\u811a\u672c\uff1a<\/p>\n
\/opt\/backup.sh 0 * * * * \r\n<\/pre>\n\u4e0b\u9762\u7684\u8868\u8fbe\u5f0f\u5728\u5468\u65e5\u7684\u51cc\u6668 3:30 \u8fd0\u884c\u5907\u4efd\u811a\u672c\uff1a<\/p>\n
\/opt\/backup.sh 30 3 * * 0 \r\n<\/pre>\n\u7b80\u5199\u8bed\u6cd5<\/strong><\/div>\n\u73b0\u4ee3\u7684 cron \u652f\u6301\u7b80\u5316\u7684\u5b8f\uff0c\u800c\u4e0d\u662f cron \u8868\u8fbe\u5f0f\uff1a<\/p>\n
@hourly \u5728\u6bcf\u5929\u7684\u6bcf\u5c0f\u65f6\u7684 0 \u5206\u8fd0\u884c<\/ol>\n@daily \u5728\u6bcf\u5929\u7684 0 \u65f6 0 \u5206\u8fd0\u884c<\/ol>\n@weekly \u5728\u5468\u65e5\u7684 0 \u65f6 0 \u5206\u8fd0\u884c<\/ol>\n@monthly \u5728\u6bcf\u6708\u7684\u7b2c\u4e00\u5929\u7684 0 \u65f6 0 \u5206\u8fd0\u884c<\/ol>\n\u4f8b\u5982\uff0c\u4e0b\u9762\u7684 crontab \u547d\u4ee4\u5728\u6bcf\u5929\u7684 0 \u65f6\u8fd0\u884c\u5907\u4efd\u811a\u672c\uff1a<\/p>\n
\/opt\/backup.sh @daily \r\n<\/pre>\n\u5982\u4f55\u505c\u6b62\u4e00\u4e2a cronjob<\/p>\n
\u4e00\u65e6\u4f60\u5f00\u59cb\u4e86\u4e00\u4e2a cronjob\uff0c\u5b83\u5c31\u4f1a\u6c38\u8fdc\u6309\u7167\u8ba1\u5212\u8fd0\u884c\u3002\u60f3\u8981\u5728\u542f\u52a8\u540e\u505c\u6b62 cronjob\uff0c\u4f60\u5fc5\u987b\u7f16\u8f91 crontab\uff0c\u5220\u9664\u89e6\u53d1\u8be5\u4f5c\u4e1a\u7684\u547d\u4ee4\u884c\uff0c\u7136\u540e\u4fdd\u5b58\u6587\u4ef6\u3002<\/p>\n
$ EDITOR=nano crontab -e \r\n<\/pre>\n\u5982\u9700\u505c\u6b62\u4e00\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u4f5c\u4e1a\uff0c\u53ef\u4ee5 \u4f7f\u7528\u6807\u51c6\u7684 Linux \u8fdb\u7a0b\u547d\u4ee4 \u6765\u505c\u6b62\u4e00\u4e2a\u6b63\u5728\u8fd0\u884c\u7684\u8fdb\u7a0b\u3002<\/p>\n
\u5b83\u662f\u81ea\u52a8\u7684<\/strong><\/div>\n\u4e00\u65e6\u4f60\u7f16\u5199\u5b8c crontab\uff0c\u4fdd\u5b58\u4e86\u6587\u4ef6\u5e76\u4e14\u9000\u51fa\u4e86\u7f16\u8f91\u5668\u3002\u4f60\u7684 cronjob \u5c31\u5df2\u7ecf\u88ab\u8c03\u5ea6\u4e86\uff0c\u5269\u4e0b\u7684\u5de5\u4f5c\u90fd\u4ea4\u7ed9 cron \u5b8c\u6210\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"
\u8981\u521b\u5efa\u4e00\u4e2a cronjob\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528 crontab \u547d\u4ee4\uff0c\u5e76\u6dfb\u52a0 -e \u9009\u9879\uff1a $ crontab -e […]<\/p>\n","protected":false},"author":1329,"featured_media":224095,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-224088","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224088","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/users\/1329"}],"replies":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/comments?post=224088"}],"version-history":[{"count":3,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224088\/revisions"}],"predecessor-version":[{"id":224115,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/posts\/224088\/revisions\/224115"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media\/224095"}],"wp:attachment":[{"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/media?parent=224088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/categories?post=224088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lrxjmw.cn\/wp-json\/wp\/v2\/tags?post=224088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}