{"id":162,"date":"2009-04-03T17:16:58","date_gmt":"2009-04-03T17:16:58","guid":{"rendered":"http:\/\/tw.newtonstudio.com\/?p=162"},"modified":"2009-04-03T17:21:08","modified_gmt":"2009-04-03T17:21:08","slug":"linux-%e7%b3%bb%e7%b5%b1%e6%8e%92%e7%a8%8b-%e5%9f%b7%e8%a1%8c-php","status":"publish","type":"post","link":"http:\/\/tw.newtonstudio.com\/?p=162","title":{"rendered":"Linux \u7cfb\u7d71\u6392\u7a0b \u57f7\u884c PHP"},"content":{"rendered":"<p>1. \u5728linux\u8f38\u5165\u6307\u4ee4: crontab -e \u9032\u884c\u7cfb\u7d71\u6392\u7a0b\u7de8\u8f2f\u6a21\u5f0f<\/p>\n<p>2. \u683c\u5f0f\u5927\u6982\u5982\u4e0b, \u524d\u97625\u500b\u6b04\u4f4d\u5206\u5225\u662f\u662f\u57f7\u884c\u7684\u65e5\u671f\u6642\u9593(\u5206 \u6642 \u65e5 \u6708 \u5e74), \u5f8c\u9762\u7684\u8def\u5f91\u662f\u8981\u57f7\u884c\u7684\u7a0b\u5f0f, \u4ee5\u4e0b\u7684\u610f\u601d\u662f\u6307\u6bcf\u5929\u7684\u51cc\u666812\u9ede\u6703\u57f7\u884c\u4e00\u6b21\u6b64\u7a0b\u5f0f:<\/p>\n<blockquote><p>\u00a00 0 * * * \/usr\/local\/www\/awstats\/cgi-bin\/awstats.sh<\/p><\/blockquote>\n<p>3. \u73fe\u5728\u6211\u5011\u8981\u6392\u7a0b\u57f7\u884cPHP\u7db2\u9801, \u56e0\u6b64\u9700\u8981\u7528LINUX\u7684PHP\u7a0b\u5f0f\u4f86\u57f7\u884cPHP\u7db2\u9801, \u6307\u4ee4\u5982\u4e0b:<\/p>\n<blockquote><p>30 23 * * * \/usr\/local\/bin\/php \/home\/xxx\/public_html\/mytesting.php &gt;&gt; \/host\/cron.log 2&gt;&amp;2<\/p><\/blockquote>\n<p>\u4ee5\u4e0a\u7684\u6307\u4ee4\u542b\u610f\u662f, \u6bcf\u5929\u7684\u665a\u4e0a11\u9ede30\u5206\u6703\u4f7f\u7528PHP\u7a0b\u5f0f(\u8def\u5f91\u5728\/usr\/local\/bin\/)\u4f86\u57f7\u884cPHP\u7db2\u9801(\u8def\u5f91\u5728\/home\/xxx\/public_html\/), \u800c\u5f8c\u9762\u7684\u610f\u601d\u662f\u57f7\u884c\u5b8c\u7562\u5f8c\u7684\u7d00\u9304\u6a94\u6703\u5ef6\u4f38\u5132\u5b58\u5728 \/host\/cron.log \u88e1\u9762, \u8b93\u4f60\u77e5\u9053\u57f7\u884c\u7684\u7d50\u679c, \u5426\u5247\u57f7\u884c\u7684\u72c0\u6cc1\u4f60\u662f\u6c92\u8fa6\u6cd5\u76f4\u63a5\u770b\u5230\u7684.(\u4f7f\u7528 * \u7684\u610f\u601d\u662f\u4e0d\u7ba1\u4f55\u5e74\u4f55\u6708\u4f55\u65e5, \u82e5\u6307\u5b9a\u65e5\u671f, \u90a3\u5c31\u8868\u793a\u53ea\u6703\u5728\u8a72\u65e5\u671f\u57f7\u884c\u4e00\u6b21) \u6240\u4ee5\u82e5\u8981\u7cfb\u7d71\u6bcf\u5929\u56fa\u5b9a\u6642\u9593\u5167\u66ff\u4f60\u57f7\u884c\u7a0b\u5f0f, \u5c31\u8981\u628a\u683c\u5f0f\u5beb\u6e05\u695a\u56c9, crontab\u7684\u6642\u9593\u683c\u5f0f\u5982\u4e0b:<\/p>\n<blockquote><p>field\u00a0\u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0 allowed values<br \/>\n&#8212;&#8211;\u00a0\u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0 &#8212;&#8212;&#8212;&#8212;&#8211;<br \/>\nminute\u00a0 \u00a0 \u00a0 \u00a0\u00a0 \u00a0\u00a0 0-59<br \/>\nhour\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0 0-23<br \/>\nday of month\u00a0\u00a0 1-31<br \/>\nmonth\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1-12 (or names, see below)<br \/>\nday of week\u00a0\u00a0\u00a0 0-7 (0 or 7 is Sun, or use names)<\/p><\/blockquote>\n<p>\u00a0\u82e5\u60f3\u77e5\u9053\u66f4\u8a73\u7d30\u7684\u8cc7\u6599, \u53ef\u4ee5\u8f38\u5165 man 5 crontab, \u53c3\u8003\u8a73\u7d30\u7684\u8aaa\u660e. \u9664\u6b64\u4e4b\u5916, \u8981\u4f8b\u884c\u57f7\u884c\u7a0b\u5f0f, \u5beb\u6cd5\u4e5f\u53ef\u4ee5\u5982\u4e0b:<\/p>\n<blockquote><p>string\u00a0 \u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 meaning<br \/>\n&#8212;&#8212;\u00a0\u00a0 \u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0 &#8212;&#8212;-<br \/>\n@reboot\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Run once, at startup.<br \/>\n@yearly\u00a0 \u00a0 \u00a0 \u00a0\u00a0 Run once a year, &#8220;0 0 1 1 *&#8221;.<br \/>\n@annually\u00a0\u00a0\u00a0\u00a0\u00a0 (same as @yearly)<br \/>\n@monthly\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Run once a month, &#8220;0 0 1 * *&#8221;.<br \/>\n@weekly\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Run once a week, &#8220;0 0 * * 0&#8221;.<br \/>\n@daily\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\u00a0 \u00a0 Run once a day, &#8220;0 0 * * *&#8221;.<br \/>\n@midnight\u00a0\u00a0\u00a0\u00a0\u00a0 (same as @daily)<br \/>\n@hourly\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 Run once an hour, &#8220;0 * * * *&#8221;.<\/p><\/blockquote>\n<p>\u5982\u679c\u6211\u60f3\u8981\u6bcf\u5206\u9418\u57f7\u884c\u4e00\u6b21, \u8981\u600e\u9ebc\u5beb?<\/p>\n<blockquote><p>*\/1 * * * * \/usr\/local\/bin\/php \/home\/xxx\/public_html\/mytesting.php &gt;&gt; \/host\/cron.log 2&gt;&amp;2<\/p><\/blockquote>\n<p>*\/1 \u5c31\u662f\u8b93\u4f60\u9023\u7e8c\u6bcf\u5206\u9418\u57f7\u884c\u4e00\u6b21\u7684\u95dc\u9375\u5beb\u6cd5.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5728linux\u8f38\u5165\u6307\u4ee4: crontab -e \u9032\u884c\u7cfb\u7d71\u6392\u7a0b\u7de8\u8f2f\u6a21\u5f0f 2. \u683c\u5f0f\u5927\u6982\u5982\u4e0b, \u524d\u97625\u500b\u6b04\u4f4d\u5206 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[68,69,70],"class_list":["post-162","post","type-post","status-publish","format-standard","hentry","category-php-","tag-crontab","tag-linux","tag-php"],"_links":{"self":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/162","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=162"}],"version-history":[{"count":4,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions"}],"predecessor-version":[{"id":165,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=\/wp\/v2\/posts\/162\/revisions\/165"}],"wp:attachment":[{"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=162"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/tw.newtonstudio.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}