{"id":287,"date":"2017-03-17T14:21:48","date_gmt":"2017-03-17T06:21:48","guid":{"rendered":"http:\/\/luchanglong.com.cn\/?p=287"},"modified":"2017-03-17T14:49:31","modified_gmt":"2017-03-17T06:49:31","slug":"linux-%e4%bd%bf%e7%94%a8crontab-%e5%81%9a%e5%ae%9a%e6%97%b6%e4%bb%bb%e5%8a%a1","status":"publish","type":"post","link":"https:\/\/blog.la998.com\/?p=287","title":{"rendered":"linux \u4f7f\u7528crontab \u505a\u5b9a\u65f6\u4efb\u52a1"},"content":{"rendered":"<div class=\"para\"><b>\u8bed\u6cd5<\/b>:<\/div>\n<div class=\"para\">crontab [-e [UserName]|-l [UserName]|-r [UserName]|-v [UserName]|File ]<\/div>\n<div class=\"para\"><b>\u8bf4\u660e<\/b>:<\/div>\n<div class=\"para\">crontab \u662f\u7528\u6765\u8ba9\u4f7f\u7528\u8005\u5728\u56fa\u5b9a\u65f6\u95f4\u6216\u56fa\u5b9a\u95f4\u9694\u6267\u884c\u7a0b\u5e8f\u4e4b\u7528\uff0c\u6362\u53e5\u8bdd\u8bf4\uff0c\u4e5f\u5c31\u662f\u7c7b\u4f3c\u4f7f\u7528\u8005\u7684\u65f6\u7a0b\u8868\u3002<\/div>\n<div class=\"para\">-u user \u662f\u6307\u8bbe\u5b9a\u6307\u5b9a user \u7684\u65f6\u7a0b\u8868\uff0c\u8fd9\u4e2a\u524d\u63d0\u662f\u4f60\u5fc5\u987b\u8981\u6709\u5176\u6743\u9650(\u6bd4\u5982\u8bf4\u662f root)\u624d\u80fd\u591f\u6307\u5b9a\u4ed6\u4eba\u7684\u65f6\u7a0b\u8868\u3002\u5982\u679c\u4e0d\u4f7f\u7528 -u user \u7684\u8bdd\uff0c\u5c31\u662f\u8868\u793a\u8bbe\u5b9a\u81ea\u5df1\u7684\u65f6\u7a0b\u8868\u3002<\/div>\n<div class=\"para\"><b>\u53c2\u6570<\/b>:<\/div>\n<div class=\"para\">-e [UserName]: \u6267\u884c\u6587\u5b57<a href=\"http:\/\/baike.baidu.com\/item\/%E7%BC%96%E8%BE%91%E5%99%A8\" target=\"_blank\">\u7f16\u8f91\u5668<\/a>\u6765\u8bbe\u5b9a\u65f6\u7a0b\u8868\uff0c\u5185\u5b9a\u7684\u6587\u5b57\u7f16\u8f91\u5668\u662f VI\uff0c\u5982\u679c\u4f60\u60f3\u7528\u522b\u7684\u6587\u5b57\u7f16\u8f91\u5668\uff0c\u5219\u8bf7\u5148\u8bbe\u5b9a VISUAL \u73af\u5883\u53d8\u6570\u6765\u6307\u5b9a\u4f7f\u7528\u90a3\u4e2a\u6587\u5b57\u7f16\u8f91\u5668(\u6bd4\u5982\u8bf4 setenv VISUAL joe)<\/div>\n<div class=\"para\">-r [UserName]: \u5220\u9664\u76ee\u524d\u7684\u65f6\u7a0b\u8868<\/div>\n<div class=\"para\">-l [UserName]: \u5217\u51fa\u76ee\u524d\u7684\u65f6\u7a0b\u8868<\/div>\n<div class=\"para\">-v [UserName]:\u5217\u51fa\u7528\u6237cron\u4f5c\u4e1a\u7684\u72b6\u6001<\/div>\n<div class=\"para\"><b>\u65f6\u7a0b\u8868\u7684\u683c\u5f0f\u5982\u4e0b<\/b>:<\/div>\n<div class=\"para\">f1 f2 f3 f4 f5 program<\/div>\n<div class=\"para\">\u5176\u4e2d f1 \u662f\u8868\u793a\u5206\u949f\uff0cf2 \u8868\u793a\u5c0f\u65f6\uff0cf3 \u8868\u793a\u4e00\u4e2a\u6708\u4efd\u4e2d\u7684\u7b2c\u51e0\u65e5\uff0cf4 \u8868\u793a\u6708\u4efd\uff0cf5 \u8868\u793a\u4e00\u4e2a\u661f\u671f\u4e2d\u7684\u7b2c\u51e0\u5929\u3002program \u8868\u793a\u8981\u6267\u884c\u7684\u7a0b\u5f0f\u3002<\/div>\n<div class=\"para\">\u5f53 f1 \u4e3a * \u65f6\u8868\u793a\u6bcf\u5206\u949f\u90fd\u8981\u6267\u884c program\uff0cf2 \u4e3a * \u65f6\u8868\u793a\u6bcf\u5c0f\u65f6\u90fd\u8981\u6267\u884c\u7a0b\u5f0f\uff0c\u5176\u4f59\u7c7b\u63a8<\/div>\n<div class=\"para\">\u5f53 f1 \u4e3a a-b \u65f6\u8868\u793a\u4ece\u7b2c a \u5206\u949f\u5230\u7b2c b \u5206\u949f\u8fd9\u6bb5\u65f6\u95f4\u5185\u8981\u6267\u884c\uff0cf2 \u4e3a a-b \u65f6\u8868\u793a\u4ece\u7b2c a \u5230\u7b2c b \u5c0f\u65f6\u90fd\u8981\u6267\u884c\uff0c\u5176\u4f59\u7c7b\u63a8<\/div>\n<div class=\"para\">\u5f53 f1 \u4e3a *\/n \u65f6\u8868\u793a\u6bcf n \u5206\u949f\u4e2a\u65f6\u95f4\u95f4\u9694\u6267\u884c\u4e00\u6b21\uff0cf2 \u4e3a *\/n \u8868\u793a\u6bcf n \u5c0f\u65f6\u4e2a\u65f6\u95f4\u95f4\u9694\u6267\u884c\u4e00\u6b21\uff0c\u5176\u4f59\u7c7b\u63a8<\/div>\n<div class=\"para\">\u5f53 f1 \u4e3a a, b, c,&#8230; \u65f6\u8868\u793a\u7b2c a, b, c,&#8230; \u5206\u949f\u8981\u6267\u884c\uff0cf2 \u4e3a a, b, c,&#8230; \u65f6\u8868\u793a\u7b2c a, b, c&#8230;\u4e2a\u5c0f\u65f6\u8981\u6267\u884c\uff0c\u5176\u4f59\u7c7b\u63a8<\/div>\n<div class=\"para\">\u4f7f\u7528\u8005\u4e5f\u53ef\u4ee5\u5c06\u6240\u6709\u7684\u8bbe\u5b9a\u5148\u5b58\u653e\u5728\u6863\u6848 file \u4e2d\uff0c\u7528 crontab file \u7684\u65b9\u5f0f\u6765\u8bbe\u5b9a\u65f6\u7a0b\u8868\u3002<\/div>\n<div class=\"para\">\u7531\u4e8e<a href=\"http:\/\/baike.baidu.com\/item\/unix\" target=\"_blank\">unix<\/a>\u7248\u672c\u4e0d\u4e00\u6837\uff0c\u6240\u4ee5\u90e8\u5206\u8bed\u6cd5\u6709\u5dee\u522b\uff0c\u4f8b\u5982\u5728hp unix aix \u4e2d\u8bbe\u5b9a\u95f4\u9694\u6267\u884c\u5982\u679c\u91c7\u7528*\/n \u65b9\u5f0f\u5c06\u51fa\u73b0\u8bed\u6cd5\u9519\u8bef\uff0c\u5728\u8fd9<a href=\"http:\/\/baike.baidu.com\/item\/%E7%B1%BBunix\" target=\"_blank\">\u7c7bunix<\/a>\u4e2d \uff0c\u95f4\u9694\u6267\u884c\u53ea\u80fd\u4ee5\u5217\u4e3e\u65b9\u5f0f\u3002<\/div>\n<div class=\"para\"><\/div>\n<div class=\"para\">\u5b9e\u4f8b\u300a\u6dfb\u52a0\u4e00\u4e2a\u6bcf\u5206\u949f\u6267\u884c\u811a\u672c\u4e00\u6b21\u7684\u5b9a\u65f6\u4efb\u52a1\u300b\uff1a<\/div>\n<div class=\"para\">1.\u521b\u5efa\u8981\u6267\u884c\u7684\u6587\u4ef6 \uff0c\u8bb0\u5f97\u66f4\u6539\u6743\u9650<\/div>\n<div class=\"para\"># vi \/root\/do.sh<\/div>\n<div class=\"para\">\u00a0\u5199\u5165\u8981\u6267\u884c\u7684\u547d\u4ee4<\/div>\n<div class=\"para\">2.\u521b\u5efa\u4efb\u52a1<\/div>\n<div class=\"para\"># crontab -e<\/div>\n<div class=\"para\">\u5728\u7f16\u8f91\u9875\u9762\u4e2d\u5199\u5165<\/div>\n<div class=\"para\">* * * * * \/root\/do.sh<\/div>\n<div class=\"para\">\u4fdd\u5b58\uff0c\u67e5\u770b\u5f53\u524d\u4efb\u52a1<\/div>\n<div class=\"para\"># crontab -l<\/div>\n<div class=\"para\"><\/div>\n<div class=\"para\">\u4efb\u52a1\u8bbe\u7f6e\u6210\u529f\uff01<\/div>\n<div class=\"para\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u8bed\u6cd5: crontab [-e [UserName]|-l [UserName]|-r [UserName]| &hellip; <a href=\"https:\/\/blog.la998.com\/?p=287\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">linux \u4f7f\u7528crontab \u505a\u5b9a\u65f6\u4efb\u52a1<\/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":[4],"tags":[],"class_list":["post-287","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.la998.com\/index.php?rest_route=\/wp\/v2\/posts\/287","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.la998.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.la998.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.la998.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.la998.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=287"}],"version-history":[{"count":3,"href":"https:\/\/blog.la998.com\/index.php?rest_route=\/wp\/v2\/posts\/287\/revisions"}],"predecessor-version":[{"id":290,"href":"https:\/\/blog.la998.com\/index.php?rest_route=\/wp\/v2\/posts\/287\/revisions\/290"}],"wp:attachment":[{"href":"https:\/\/blog.la998.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=287"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.la998.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=287"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.la998.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=287"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}