{"id":52028,"date":"2024-12-03T17:00:30","date_gmt":"2024-12-03T09:00:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/52028\/"},"modified":"2024-12-03T17:00:30","modified_gmt":"2024-12-03T09:00:30","slug":"linux%e5%ae%9a%e6%97%b6%e6%89%a7%e8%a1%8cphp%e5%90%af%e5%8a%a8%e4%bb%bb%e5%8a%a1%e8%84%9a%e6%9c%ac%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/52028\/","title":{"rendered":"linux\u5b9a\u65f6\u6267\u884cphp\u542f\u52a8\u4efb\u52a1\u811a\u672c\u600e\u4e48\u5199"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>linux\u5b9a\u65f6\u6267\u884cphp\u542f\u52a8\u4efb\u52a1\u811a\u672c\u600e\u4e48\u5199<\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300alinux\u5b9a\u65f6\u6267\u884cphp\u542f\u52a8\u4efb\u52a1\u811a\u672c\u600e\u4e48\u5199\u300b<\/span>\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><strong>\u7b2c\u4e00\u6b65\uff1a<\/strong>\u521b\u5efa\u4e00\u4e2a\u5b9a\u65f6\u811a\u672c\u6587\u4ef6cron.sh\uff08\u6587\u4ef6\u540d\u968f\u610f\u4ee5.sh\u7ed3\u5c3e\uff09\u3002<\/p>\n<p>\u53c2\u8003\u4ee3\u7801\u5982\u4e0b\uff08log.txt\u662f\u4e2a\u65e5\u5fd7\u6587\u4ef6\u65b9\u4fbf\u67e5\u770b\u662f\u5426\u6709\u8f93\u51fa\u5185\u5bb9\uff09\uff1a<\/p>\n<pre>echo&nbsp;\"supervisorctl&nbsp;restart...\"&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt\nstart_time=$(date)\necho&nbsp;$start_time&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt\necho&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt\nsupervisorctl&nbsp;restart&nbsp;all\nend_time=$(date)\necho&nbsp;\"supervisorctl&nbsp;end\"&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt\necho&nbsp;$end_time&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt\necho&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt<\/pre>\n<p>\u6211\u8fd9\u8fb9\u5229\u7528supervisorctl\u6765\u7ba1\u7406php\u8fdb\u7a0b\uff08\u5173\u4e8esupervisorctl\u7684\u4f7f\u7528\u53ef\u4ee5\u67e5\u770b\u5b98\u65b9\u6587\u6863\uff09,\u5f53\u7136\u4e5f\u53ef\u4ee5\u5229\u7528\u5176\u4ed6\u65b9\u5f0f\u3002<\/p>\n<p>\u8fd9\u91cc\u4e3e\u4e2a\u4f8b\u5b50\u6765\u7b80\u5355\u8bf4\u660esupervisorctl\u7684\u4f7f\u7528\u3002<\/p>\n<p>\u9996\u5148\u9700\u8981\u5b89\u88c5supervisorctl\uff0c\u5728\u7ec8\u7aef\u4e0b\u6267\u884c yum install -y supervisor,<\/p>\n<p>supervisorct\u9ed8\u8ba4\u5b89\u88c5\u5728\/etc\/supervisor\u76ee\u5f55\u4e0b\uff1b<\/p>\n<p>\u5b8c\u6210\u540e\uff0c\u5728\/etc\/supervisor \u8def\u5f84\u4e0b\u6709\u4e2a\u914d\u7f6e\u6587\u4ef6supervisord.conf\uff0c\u6253\u5f00\u540e\u5728\u6700\u540e\u6709\u4e2a[include]\u540e\u914d\u7f6e\u4e00\u4e0bfiles\u5982\u4e0b\uff1a<\/p>\n<pre>files&nbsp;=&nbsp;\/etc\/supervisor\/conf.d\/*.conf<\/pre>\n<p>\u7136\u540e\u5c31\u53ef\u4ee5\u5728\/etc\/supervisor\/conf.d\u76ee\u5f55\u4e0b\u521b\u5efa\u81ea\u5df1\u7684\u914d\u7f6e\u6587\u4ef6\uff1b<\/p>\n<p>\u4f8b\u5982\u521b\u5efa\u6587\u4ef6test.conf\uff08\u6211\u8fd9\u8fb9\u662fphp laravel\u6846\u67b6\u6267\u884c\u7684\u4e00\u4e2a\u6d88\u8d39\u4efb\u52a1\u961f\u5217\uff09\u6587\u4ef6\u5185\u5bb9\u914d\u7f6e\u5982\u4e0b\uff1a<\/p>\n<pre>[program:rabbitmq-comsumer-1]\nprocess_name=%(program_name)s_1\ncommand=php&nbsp;\/var\/www\/html\/app\/artisan&nbsp;rabbitmq:consumer&nbsp;1\nautostart=true\nautorestart=true\nuser=root\nnumprocs=1\nredirect_stderr=true\nstdout_logfile=\/var\/www\/html\/app\/storage\/logs\/rabbitmq-comsumer-log-1.log<\/pre>\n<p><strong>\u7b2c\u4e8c\u6b65\uff1a<\/strong>\u5176\u6b21\u7f16\u5199\u5b9a\u65f6\u4efb\u52a1\u5185\u5bb9\uff0c\u5728\u7ec8\u7aef\u63a7\u5236\u53f0\u8f93\u5165 vim \/etc\/crontab \u56de\u8f66\uff1b\u5728\u6587\u4ef6\u91cc\u5199\u5165\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>0&nbsp;*\/2&nbsp;*&nbsp;*&nbsp;*&nbsp;root&nbsp;&nbsp;\/var\/www\/html\/cron.sh<\/pre>\n<p>\u6ce8\uff1a0 *\/2 * * *\uff08\u8fd9\u662f\u5b9a\u65f6\u4efb\u52a1\u6267\u884c\u8bed\u6cd5\uff0c\u6211\u8fd9\u8fb9\u662f\u6bcf2\u5c0f\u65f6\u6267\u884c\uff0c\u4e5f\u5c31\u662f0:00,2:00,&#8230;\u81ea\u52a8\u6267\u884c\uff1b\u76f8\u5173\u8bed\u6cd5\u8bf7\u767e\u5ea6\u67e5\u9605\uff09<\/p>\n<p><strong>\u7b2c\u4e09\u6b65\uff1a<\/strong>\u4fdd\u5b58\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u5176\u751f\u6548\uff08\u8fd9\u4e00\u6b65\u5f88\u91cd\u8981\uff01\uff09\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre>crontab&nbsp;\/ect\/crontab<\/pre>\n<p>\u6700\u540e\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u4fee\u6539\u540e\u7684\u7ed3\u679c\uff0c\u5982\u679c\u770b\u5230\u51fa\u73b0 0 *\/2 * * * root &nbsp;\/var\/www\/html\/cron.sh \u5219\u8bf4\u660e\u5df2\u7ecf\u751f\u6548\uff1a<\/p>\n<pre>crontab&nbsp;-l<\/pre>\n<p>\u4eca\u5929\u5e26\u5927\u5bb6\u4e86\u89e3\u4e86\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u5e0c\u671b\u5bf9\u4f60\u6709\u6240\u5e2e\u52a9\uff1b\u5173\u4e8e\u6587\u7ae0\u7684\u6280\u672f\u77e5\u8bc6\u6211\u4eec\u4f1a\u4e00\u70b9\u70b9\u6df1\u5165\u4ecb\u7ecd\uff0c\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\uff0c\u4e00\u8d77\u5b66\u4e60\u7f16\u7a0b~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>linux\u5b9a\u65f6\u6267\u884cphp\u542f\u52a8\u4efb\u52a1\u811a\u672c\u600e\u4e48\u5199 \u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\u300alinux\u5b9a\u65f6\u6267\u884cphp\u542f\u52a8\u4efb\u52a1\u811a\u672c\u600e\u4e48\u5199\u300b\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01 \u7b2c\u4e00\u6b65\uff1a\u521b\u5efa\u4e00\u4e2a\u5b9a\u65f6\u811a\u672c\u6587\u4ef6cron.sh\uff08\u6587\u4ef6\u540d\u968f\u610f\u4ee5.sh\u7ed3\u5c3e\uff09\u3002 \u53c2\u8003\u4ee3\u7801\u5982\u4e0b\uff08log.txt\u662f\u4e2a\u65e5\u5fd7\u6587\u4ef6\u65b9\u4fbf\u67e5\u770b\u662f\u5426\u6709\u8f93\u51fa\u5185\u5bb9\uff09\uff1a echo&nbsp;&#8220;supervisorctl&nbsp;restart&#8230;&#8221;&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt start_time=$(date) echo&nbsp;$start_time&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt echo&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt supervisorctl&nbsp;restart&nbsp;all end_time=$(date) echo&nbsp;&#8220;supervisorctl&nbsp;end&#8221;&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt echo&nbsp;$end_time&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt echo&nbsp;&gt;&gt;&nbsp;\/var\/www\/html\/log.txt \u6211\u8fd9\u8fb9\u5229\u7528supervisorctl\u6765\u7ba1\u7406php\u8fdb\u7a0b\uff08\u5173\u4e8esupervisorctl\u7684\u4f7f\u7528\u53ef\u4ee5\u67e5\u770b\u5b98\u65b9\u6587\u6863\uff09,\u5f53\u7136\u4e5f\u53ef\u4ee5\u5229\u7528\u5176\u4ed6\u65b9\u5f0f\u3002 \u8fd9\u91cc\u4e3e\u4e2a\u4f8b\u5b50\u6765\u7b80\u5355\u8bf4\u660esupervisorctl\u7684\u4f7f\u7528\u3002 \u9996\u5148\u9700\u8981\u5b89\u88c5supervisorctl\uff0c\u5728\u7ec8\u7aef\u4e0b\u6267\u884c yum install -y supervisor, supervisorct\u9ed8\u8ba4\u5b89\u88c5\u5728\/etc\/supervisor\u76ee\u5f55\u4e0b\uff1b \u5b8c\u6210\u540e\uff0c\u5728\/etc\/supervisor \u8def\u5f84\u4e0b\u6709\u4e2a\u914d\u7f6e\u6587\u4ef6supervisord.conf\uff0c\u6253\u5f00\u540e\u5728\u6700\u540e\u6709\u4e2a[include]\u540e\u914d\u7f6e\u4e00\u4e0bfiles\u5982\u4e0b\uff1a files&nbsp;=&nbsp;\/etc\/supervisor\/conf.d\/*.conf \u7136\u540e\u5c31\u53ef\u4ee5\u5728\/etc\/supervisor\/conf.d\u76ee\u5f55\u4e0b\u521b\u5efa\u81ea\u5df1\u7684\u914d\u7f6e\u6587\u4ef6\uff1b \u4f8b\u5982\u521b\u5efa\u6587\u4ef6test.conf\uff08\u6211\u8fd9\u8fb9\u662fphp laravel\u6846\u67b6\u6267\u884c\u7684\u4e00\u4e2a\u6d88\u8d39\u4efb\u52a1\u961f\u5217\uff09\u6587\u4ef6\u5185\u5bb9\u914d\u7f6e\u5982\u4e0b\uff1a [program:rabbitmq-comsumer-1] process_name=%(program_name)s_1 command=php&nbsp;\/var\/www\/html\/app\/artisan&nbsp;rabbitmq:consumer&nbsp;1 autostart=true autorestart=true user=root numprocs=1 redirect_stderr=true stdout_logfile=\/var\/www\/html\/app\/storage\/logs\/rabbitmq-comsumer-log-1.log \u7b2c\u4e8c\u6b65\uff1a\u5176\u6b21\u7f16\u5199\u5b9a\u65f6\u4efb\u52a1\u5185\u5bb9\uff0c\u5728\u7ec8\u7aef\u63a7\u5236\u53f0\u8f93\u5165 vim \/etc\/crontab \u56de\u8f66\uff1b\u5728\u6587\u4ef6\u91cc\u5199\u5165\u5982\u4e0b\u4ee3\u7801\uff1a 0&nbsp;*\/2&nbsp;*&nbsp;*&nbsp;*&nbsp;root&nbsp;&nbsp;\/var\/www\/html\/cron.sh \u6ce8\uff1a0 *\/2 * * *\uff08\u8fd9\u662f\u5b9a\u65f6\u4efb\u52a1\u6267\u884c\u8bed\u6cd5\uff0c\u6211\u8fd9\u8fb9\u662f\u6bcf2\u5c0f\u65f6\u6267\u884c\uff0c\u4e5f\u5c31\u662f0:00,2:00,&#8230;\u81ea\u52a8\u6267\u884c\uff1b\u76f8\u5173\u8bed\u6cd5\u8bf7\u767e\u5ea6\u67e5\u9605\uff09 \u7b2c\u4e09\u6b65\uff1a\u4fdd\u5b58\u6587\u4ef6\uff0c\u7136\u540e\u4f7f\u5176\u751f\u6548\uff08\u8fd9\u4e00\u6b65\u5f88\u91cd\u8981\uff01\uff09\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a crontab&nbsp;\/ect\/crontab \u6700\u540e\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u67e5\u770b\u4fee\u6539\u540e\u7684\u7ed3\u679c\uff0c\u5982\u679c\u770b\u5230\u51fa\u73b0 0 *\/2 * * * root [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-52028","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52028","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=52028"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/52028\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=52028"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=52028"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=52028"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}