{"id":3315,"date":"2017-12-07T17:08:41","date_gmt":"2017-12-07T09:08:41","guid":{"rendered":"https:\/\/dmesg.app\/?p=3315"},"modified":"2017-12-17T21:44:36","modified_gmt":"2017-12-17T13:44:36","slug":"linux-keep-running","status":"publish","type":"post","link":"https:\/\/dmesg.app\/linux-keep-running.html","title":{"rendered":"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5"},"content":{"rendered":"<div  class=\"sc_act\">\u8fd9\u7bc7\u6587\u7ae0\u5728 2017\u5e7412\u670817\u65e521:44:36 \u66f4\u65b0\u4e86\u54e6~<\/div><p><span style=\"font-size: 12pt;\">\u8fd9\u6bb5\u65f6\u95f4\uff0c\u6709\u5c0f\u4f19\u4f34\u95ee\u6211\uff0c\u600e\u4e48\u80fd\u8ba9\u7a0b\u5e8f\u5728\u5173\u6389ssh\u4e4b\u540e\u8fd8\u80fd\u7ee7\u7eed\u8fd0\u884c\uff1f\u6211\u7b80\u5355\u7684\u7684\u8bf4\u4e86\u4e00\u53e5\u5f00\u4e2ascreen\u5427\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5b9e\u9645\u4e0a\u5462\uff0c<del>\u5728\u8fd9\u4e4b\u540e\u8fd8\u662f\u6709\u4e00\u4e9b\u6bd4\u8f83\u6df1\u5965\u7684\u539f\u7406\u7684\uff0c\u54b1\u5c31\u626f\u626f<\/del>\u3002<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u4e0d\u5f97\u4e0d\u7684\u8bf4\u7684SSH<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u7528Windows\u7684\u8fdc\u7a0b\u684c\u9762\u7684\u65f6\u5019\uff0c\u54b1\u53ef\u80fd\u6709\u8fd9\u79cd\u611f\u53d7\uff1a\u628a\u8fdc\u7a0b\u684c\u9762\u65ad\u5f00\u4e86\uff0c\u91cc\u9762\u7684\u7a0b\u5e8f\u4e5f\u6b22\u5feb\u7684\u8dd1\u7740\u03b5=\u03b5=\u03b5=(~\uffe3\u25bd\uffe3)~\u4f46\u662f\u5728Linux\u6211\u4eec\u628assh\u8fde\u63a5\u65ad\u5f00\uff0c\u6b63\u5728\u8dd1\u7684\u7a0b\u5e8f\u5374\u4f1a\u7acb\u523b\u6302\u6389\u3002\u8fd9\u662f\u4e3a\u5565\u634f~(\uffe3\u25bd\uffe3)~*<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u8bdd\u8bf4\uff0c\u54b1\u8fde\u63a5\u5230\u670d\u52a1\u5668\uff0c\u90fd\u662f\u6709sshd\u8fd9\u4e2a\u670d\u52a1\u6765\u8d1f\u8d23\u7684\uff1b\u8fde\u63a5\u6210\u529f\u4e4b\u540e\uff0csshd\u4f1a\u542f\u52a8bash\uff0c\u4e4b\u540e\u54b1\u5728\u8fd0\u884c\u7684\u547d\u4ee4\u4ec0\u4e48\u7684\uff0c\u76f8\u5f53\u4e8ebash\u6765\u5e2e\u6211\u4eec\u542f\u52a8\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6b64\u65f6\u7684\u8fdb\u7a0b\u6811\u5927\u6982\u662f\u8fd9\u4e48\u6837\u5b50\u7684\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">init-&gt;sshd-&gt;bash-&gt;some_program<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u901a\u8fc7<code>pstree<\/code>\u53ef\u4ee5\u5927\u6982\u770b\u5230\u8fdb\u7a0b\u6811\u7684\u7ed3\u6784<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708053786.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u4e0d\u80fd\u7ee7\u7eed\u8bb2\u4e86\uff0c\u56e0\u4e3a\u6b64\u65f6\u6211\u4eec\u8981\u8bf4\u4fe1\u53f7\u91cf\uff01<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u4fe1\u53f7\u91cf<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u5728\u4e0d\u8fdc\u7684\u8fc7\u53bb\uff0c\u6709\u4e00\u95e8\u8bfe\u53eb\u300a\u64cd\u4f5c\u7cfb\u7edf\u300b\uff0c\u6709\u4e00\u4e2a\u7ae0\u8282\u53eb\u4fe1\u53f7\u91cf\uff0c\u6709\u4e00\u4e2a\u54e5\u4eec\u53eb<a href=\"https:\/\/zh.wikipedia.org\/wiki\/%E8%89%BE%E5%85%B9%E8%B5%AB%E5%B0%94%C2%B7%E6%88%B4%E5%85%8B%E6%96%AF%E7%89%B9%E6%8B%89\" target=\"_blank\" rel=\"noopener\">\u8fea\u6770\u65af\u7279\u62c9<\/a>\u6211\u4e00\u76f4\u7ba1\u4ed6\u53eb\u8fea\u6770\u7279\u65af\u62c9\uff08\u7231\u8fea\u751f\uff1a\u8bf4\u597d\u7684\u4f60\u7231\u6211\u5462\uff09<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5657\uff0c\u8dd1\u9898\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u8bdd\u8bf4\u5728Linux\u4e0b\uff0c\u54b1\u662f\u5982\u4f55\u505c\u6b62\u67d0\u4e2a\u7a0b\u5e8f\u8fd0\u884c\u7684\u5462\uff1fCtrl+C\uff0c\u6ca1\u9519\uff0c\u4f46\u662f\u53ea\u6709\u524d\u53f0\u8fdb\u7a0b\u624d\u4f1a\u4f53\u9a8c\u5230\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u901a\u5e38\u6765\u8bf4\uff0c\u54b1\u4f1a\u4f7f\u7528kill\u6765\u7ed3\u675f\u67d0\u4e2a\u8fdb\u7a0b\u3002kill\u547d\u4ee4\u4f1a\u7ed9\u8fdb\u7a0b\u53d1\u9001\u4e00\u4e2a\u4fe1\u53f7\uff0c\u7136\u540e\u7531\u8fdb\u7a0b\u6765\u5904\u7406\uff08\u6355\u83b7\uff09\u8fd9\u4e2a\u4fe1\u53f7\u3002\u8fd9\u5c31\u597d\u50cf\u662f\u533b\u751f\u8ddf\u4f60\u8bf4\uff0c\u4f60\u53ef\u4ee5\u6b7b\u4e86\uff0c\u7136\u540e\u4f60\u5c31\u9009\u62e9\u2026\u2026\u81ea\u6740\u5417\/(\u3112o\u3112)\/~~<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">kill\u7528\u6cd5\u5f88\u7b80\u5355\uff0c\u7b80\u5355\u70b9\uff0c\u4e00\u4e2aPID\uff1b\u590d\u6742\u70b9\uff0c\u4e00\u4e2asignal\uff0c\u4e00\u4e2aPID\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u4e5f\u5c31\u662f\u8bf4\uff0c\u4f60\u60f3\u6740\u6389PID\u4e3a1087\u7684\u8fdb\u7a0b\uff0c\u6e29\u67d4\u70b9\u5c31<code>kill 1087<\/code>\u597d\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u9ed8\u8ba4\u6765\u8bf4\uff0ckill\u4f1a\u53d1\u9001SIGTERM\u8fd9\u4e2a\u4fe1\u53f7\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u4f7f\u7528<code>kill -l<\/code>\u53ef\u4ee5\u5217\u51fa\u6765\u6240\u6709\u7684\u4fe1\u53f7\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708053951.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u901a\u5e38\u6709\u8fd9\u4e48\u51e0\u4e2a\u4fe1\u53f7\u662f\u6bd4\u8f83\u5e38\u7528\u7684\u3001\u5e94\u8be5\u88ab\u8bb0\u4f4f\u7684\uff1a<\/span><\/p>\n<blockquote><p><span style=\"font-size: 12pt;\">1 - SIGHUP\uff1a\u6302\u8d77\u4fe1\u53f7\uff0c\u5f53\u7ec8\u7aef\u8fde\u63a5\u65ad\u5f00\u65f6\u5c31\u4f1a\u53d1\u9001\u8fd9\u4e2a\u4fe1\u53f7\uff1b<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">2 - SIGINT\uff1a\u4e2d\u65ad\u4fe1\u53f7\uff0c\u4e5f\u5c31\u662f\u6309Ctrl+C\uff1b<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">9 - SIGKILL\uff1a\u6700\u5f3a\u5927\u7684\u4fe1\u53f7\uff0c\u76f8\u5f53\u4e8e\u7206\u5934\u51fb\u6740\uff0c\u4e0d\u80fd\u88ab\u6355\u83b7\uff1b\u8fdb\u7a0b\u6536\u5230\u8fd9\u4e2a\u4fe1\u53f7\u5c31\u4f1a\u7acb\u523b\u62dc\u62dc\uff1b<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">15 - SIGTERM\uff1a\u7ec8\u6b62\u4fe1\u53f7\uff0ckill\u9ed8\u8ba4\u53d1\u9001\u7684\u4fe1\u53f7\uff0c\u8fd9\u5c31\u662f\u544a\u8bc9\u8fdb\u7a0b\u5c3d\u53ef\u80fd\u7684\u7ec8\u6b62\uff0c\u54b1\u5f97\u8ddf\u8fdb\u7a0b\u7238\u7238\u4e00\u4e2a\u544a\u522b\u513f\u5973\u6536\u62fe\u5584\u540e\u7684\u4e00\u4e2a\u673a\u4f1a\u561b\uff1b<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">19 - SIGSTOP\uff1a\u4e2d\u65ad\u8fdb\u7a0b\uff0c\u4e5f\u4e0d\u80fd\u88ab\u6355\u83b7\u3002\u54b1\u522b\u770b\u8fd9\u91cc\u5199\u7684\u662fSTOP\uff0c\u5b9e\u9645\u4e0a\u662f\u6682\u505c\u7684\u610f\u601d\u5566\uff0c\u7b49\u540c\u4e8eCtrl+Z\u3002\u752818\u53f7\u5c31\u6062\u590d\u4e86~<\/span><\/p><\/blockquote>\n<p><span style=\"font-size: 12pt;\">\u8fd9\u8bdd\u8bf4\u7684\u592a\u62bd\u8c61\u4e86\uff0c\u54b1\u4e0d\u5982\u5199\u4e2abash\u811a\u672c\u6765\u4f53\u9a8c\u4e00\u4e0b\u8fd9\u51e0\u4e2a\u4fe1\u53f7\u91cf\u5427\u3002<\/span><\/p>\n<pre class=\"prettyprint linenums\">#!\/bin\/bash\r\ntrap &quot;&quot; INT\r\nsleep 10\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u8fd9\u4ee3\u7801\u4e0d\u80fd\u518d\u7b80\u5355\u4e86\u3002\u8fd0\u884c\u8fd9\u4e2a\u811a\u672c\uff0c\u7136\u540e\u6309Ctrl+C\uff0c\u54b1\u4f1a\u53d1\u73b0\u8fd9\u7a0b\u5e8f\u5e76\u4e0d\u9000\u51fa\uff0c <img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708054170.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u56e0\u4e3aINT\u88ab\u6355\u83b7\u5e76\u5ffd\u7565\u5566\u3002<\/span><br \/>\n<div id=\"sc_tips\"><span style=\"font-size: 12pt;\">\u5907\u6ce8\uff1a<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u5176\u5b9ebash\u7684\u5751\u5f88\u591a\uff0c\u6bd4\u5982\u8bf4\uff0ctrap\u5565\u65f6\u5019\u8fd0\u884c\uff1f\u54b1\u4ee5\u4e0a\u7684\u76f4\u89c9\u53ef\u80fd\u662f\uff0c\u63a5\u6536\u5230\u5bf9\u5e94\u7684\u4fe1\u53f7\uff0ctrap\u5c31\u4f1a\u7acb\u523b\u505a\u51fa\u76f8\u5e94\u4e0e\u5904\u7406\u3002\u5176\u5b9e\u4e0d\u662f\u7684.<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u5b9e\u9645\u4e0a\uff0cbash\u7684\u884c\u4e3a\u6bd4\u8f83\u7279\u6b8a\u3002\u5f53\u6309\u4e0b CTRL-C \u4e4b\u540e\uff0c\u5b83\u4f1a\u5411\u5f53\u524d\u7684\u6574\u4e2a\u8fdb\u7a0b\u7ec4\u53d1\u51fa SIGINT \u4fe1\u53f7\u3002\u800c sleep \u662f\u7531\u5f53\u524d\u811a\u672c\u8c03\u7528\u7684\uff0c\u662f\u8fd9\u4e2a\u811a\u672c\u7684\u5b50\u8fdb\u7a0b\uff08<code>\/bin\/sleep<\/code>\uff09\u3002<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u5982\u679c\u5f53\u524d\u6b63\u6709\u4e00\u4e2a\u5916\u90e8\u547d\u4ee4\uff08<code>\/bin\/sleep<\/code>\uff09\u5728\u524d\u53f0\u6267\u884c\uff0c\u90a3\u4e48 trap \u4f1a\u7b49\u5f85\u5f53\u524d\u547d\u4ee4\u7ed3\u675f\u4ee5\u540e\u518d\u5904\u7406\u4fe1\u53f7\u961f\u5217\u4e2d\u7684\u4fe1\u53f7\u3002\u4e5f\u5c31\u662ftrap\u8981\u7b49sleep\u6267\u884c\u5b8c\u624d\u4f1a\u6355\u6349\u5230\u4e86\u4fe1\u53f7\u3002<\/span><\/div><\/p>\n<h2><span style=\"font-size: 12pt;\">\u524d\u53f0\u540e\u53f0\u4e0e\u4f5c\u4e1a\u63a7\u5236<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u6b63\u5e38\u54b1\u4eec\u7684\u7a0b\u5e8f\u662f\u8dd1\u5728\u524d\u53f0\u7684\uff0c\u5982\u679c\u60f3\u8dd1\u5230\u540e\u53f0\uff0c\u90a3\u4e48\u547d\u4ee4\u7ed3\u5c3e\u52a0\u4e2a<code>&amp;<\/code>\u5c31\u597d\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6bd4\u5982\u8bf4<code>bash demo.sh&amp;<\/code>\u90a3\u5c31\u88ab\u4e22\u5230\u540e\u53f0\u53bb\u6267\u884c\u4e86\uff0c\u6267\u884c\u5b8c\u6210\u4f1a\u5f39\u51fa\u6765\u544a\u8bc9\u6211\u4eecdone<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708054281.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u628a\u6b63\u5728\u8fd0\u884c\u7684\u6682\u505c\u5e76\u4e22\u5230\u540e\u53f0\uff0c\u90a3\u5c31Ctrl+Z\uff1b\u67e5\u770b\u4f5c\u4e1a\u5217\u8868\uff0c\u5c31\u7528<code>jobs<\/code>\uff1b\u62ff\u56de\u524d\u53f0\u5c31\u7528<code>fg<\/code>\uff1b\u628a\u6682\u505c\u7684\u7ee7\u7eed\u8fd0\u884c\u5c31\u7528<code>bg<\/code>\u2026\u2026<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u4e0d\u77e5\u9053\u5927\u5bb6\u61c2\u4e86\u6ca1\uff0c\u54c8\u54c8\u54c8\u54c8\u3002<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u8fde\u63a5\u65ad\u5f00\u65f6<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u9996\u5148\u54b1\u8981\u77e5\u9053\uff0c\u6302\u65ad\u4fe1\u53f7\uff08SIGHUP\uff09\u9ed8\u8ba4\u7684\u52a8\u4f5c\u662f\u7ec8\u6b62\u7a0b\u5e8f\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u90a3\u7236\u8fdb\u7a0b\u8981\u662f\u5148\u88ab\u7ec8\u6b62\u3001\u9000\u51fa\u4e86\uff0c\u5b50\u8fdb\u7a0b\u4f1a\u600e\u4e48\u6837\uff1f\u4e00\u822c\u6765\u8bf4\u6709\u4e24\u79cd\uff1a<\/span><\/p>\n<ol>\n<li><span style=\"font-size: 12pt;\">\u8fc7\u7ee7\uff08\u6536\u517b\uff09\u7ed9init\uff0c\u5b64\u513f\u8fdb\u7a0b<\/span><\/li>\n<li><span style=\"font-size: 12pt;\">\u88ab\u5212\u4e3a\u5b64\u513f\u8fdb\u7a0b\u7ec4\uff0cSIGHUP\u6740\u6b7b<\/span><\/li>\n<\/ol>\n<p><div id=\"sc_blue\"><span style=\"font-size: 12pt;\">\u5c0f\u63d0\u793a\uff1a<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u5b64\u513f\u8fdb\u7a0b\u662f\u5148\u6b7b\u4e86\u7239\u7684\u8fdb\u7a0b\uff0c\u53ef\u80fd\u4f1a\u6709\u7ee7\u7236\uff08init\uff09\uff0c\u4e5f\u53ef\u80fd\u88ab\u5f52\u5165\u8fdb\u7a0b\u7ec4\u7136\u540e\u88abSIGHUP\u6740\u6b7b\uff1b<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u90a3\u8981\u662f\u5b50\u8fdb\u7a0b\u5148\u6b7b\u4e86\u5462\uff1f\u81ea\u7136\u5b50\u8fdb\u7a0b\u4f1a\u5148\u628a\u8d44\u6e90\u91ca\u653e\uff0c\u7136\u540e\u7236\u8fdb\u7a0b\u4f1a\u7ed9\u6536\u5c38\uff08\u8c03\u7528wait\uff09\uff0c\u7136\u540e\u5185\u6838\u56de\u6536\u8fdb\u7a0b\u63a7\u5236\u5757\uff08PCB\uff09\u3002\u5047\u5982\u7236\u8fdb\u7a0b\u56e0\u4e3a\u79cd\u79cd\u539f\u56e0\u6ca1\u8c03\u7528wait\u90a3\u4e48\u5b50\u8fdb\u7a0b\u7684PCB\u4ecd\u7136\u4fdd\u5b58\u5728\u7cfb\u7edf\u4e2d\uff0c\u5c31\u6210\u4e3a\u4e86\u50f5\u5c38\u8fdb\u7a0b\u3002\u653e\u5fc3\uff0ckill 9\u662f\u6740\u4e0d\u6389\u50f5\u5c38\u8fdb\u7a0b\u7684\uff0c\u9047\u5230\u50f5\u5c38\u8fdb\u7a0b\u5c31\u6740\u6b7b\u5bf9\u5e94\u7684\u7236\u8fdb\u7a0b\uff0c\u7136\u540einit\u5c31\u4f1a\u6210\u4e3a\u50f5\u5c38\u8fdb\u7a0b\u7684\u7239\uff0c\u4e4b\u540ewait\u56de\u6536\u3002<\/span><\/div><br \/>\n<span style=\"font-size: 12pt;\">\u7b80\u5355\u7684\u8bf4\uff0csshd\u53d1\u73b0\u8fde\u63a5\u65ad\u5f00\u4e4b\u540e\uff0cbash\u6536\u5230SIGHUP\u4fe1\u53f7\u4ece\u800c\u5173\u95ed\u5176\u6240\u6709\u5b50\u8fdb\u7a0b\u3002(\u6ce8\u610f\uff0cbash\u7684\u884c\u4e3a\u6bd4\u8f83\u8be1\u5f02\uff0c\u5982\u679c\u662f\u8f93\u5165exit\uff0c\u90a3\u5c31\u4e0d\u4f1a\u53d1\u9001SIGHUP\uff0c\u4e5f\u5c31\u662f\u8bf4\u4f60exit\u9000\u51fa\u7684\uff0c\u90a3\u4e48\u811a\u672c\u8fd8\u662f\u6b22\u5feb\u7684\u8dd1\u4e0b\u53bb\u7684)<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6240\u4ee5\u81ea\u7136\u7ec8\u7aef\u65ad\u4e86\uff0c\u5927\u5bb6\u90fd\u88abSIGHUP\u5e72\u6389\u4e86\u5457~SIGHUP\u662f\u5143\u51f6\u554a\uff01<\/span><br \/>\n<div id=\"sc_notice\"><br \/>\n<span style=\"font-size: 12pt;\">\u4e00\u70b9\u70b9\u5c0f\u5b9e\u9a8c\uff1a<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u8ba9\u6211\u4eec\u8fde\u5230\u670d\u52a1\u5668\uff0c\u7136\u540e<code>systemctl stop sshd.service<\/code>\uff0c\u7136\u540e\u60ca\u5947\u7684\u53d1\u73b0\u5f53\u524d\u7ec8\u7aef\u8fd8\u6d3b\u7740\u3002\u60f3\u60f3\u8fd9\u662f\u4e3a\u4ec0\u4e48\uff1f\u540e\u9762\u6211\u4f1a\u8bf4\u7684\u2026\u2026<\/span><br \/>\n<span style=\"font-size: 12pt;\">\u597d\u4e86\u8d76\u7d27\u542f\u52a8\u5427\uff0c\u8981\u4e0d\u5f53\u524d\u8fde\u63a5\u6302\u4e86\u90a3\u5c31\u4e0d\u597d\u73a9\u4e86\u3002<\/span><\/div><\/p>\n<h2><span style=\"font-size: 12pt;\">\u4fdd\u6301\u7a0b\u5e8f\u53ef\u9760\u8fd0\u884c\u7684\u51e0\u79cd\u65b9\u6cd5<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u65e2\u7136\u54b1\u90fd\u77e5\u9053\u662f\u56e0\u4e3aSIGHUP\u5173\u95ed\u7684\u4e86\uff0c\u90a3\u54b1\u8ba9\u7a0b\u5e8f\u5ffd\u7565\u8fd9\u4e2a\u4fe1\u53f7\u4e0d\u5c31\u597d\u4e86\u561b\uff01<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">\u51e0\u79cd\u4e0d\u597d\u7528\u7684\u529e\u6cd5<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u6bd4\u5982\u8bf4<code>&amp;<\/code>\uff0cCtrl+Z\uff0c\u8fd9\u90fd\u662f\u4e0d\u597d\u7528\u7684\u2026\u2026\u7167\u6837\u8fd8\u662f\u5904\u4e8e\u4e00\u4e2asession\u4e2d\uff0c\u8fd8\u662fsshd-&gt;bash-&gt;program\uff0c\u8fd8\u662f\u4f1a\u6536\u5230SIGHUP\u7136\u540e\u62dc\u62dc\u3002<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">nohup<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">SIGHUP\u662f\u5143\u51f6\uff0c\u90a3\u4e48<code>nohup<\/code>\u5c31\u597d\u4e86\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6bd4\u5982\u8bf4\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">nohup ping z.cn\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u8fd9\u6837\u7a0b\u5e8f\u7684\u8f93\u51fa\u4f1a\u88ab\u91cd\u5b9a\u5411\u5230<code>nohup.out<\/code>\u4e2d\uff0c\u66f4\u901a\u5e38\u6211\u4eec\u4f1a<code>nohup ping z.cn &amp;<\/code>\u987a\u4fbf\u7ed9\u4e22\u5230\u540e\u53f0\uff0c\u6b64\u65f6\u8fdb\u7a0b\u6811\u8fd8\u662finit-&gt;sshd-&gt;bash-&gt;ping\uff0c\u5982\u679c\u6211\u4eec\u5173\u95ed\u7ec8\u7aef\uff0c\u90a3\u4e48<code>ping<\/code>\u5c31\u4f1a\u6210\u4e3a\u5b64\u513f\u8fdb\u7a0b\uff0c\u7136\u540e\u8fc7\u7ee7\u7ed9init\uff0c\u6b64\u65f6\u6211\u4eec<code>pstree<\/code>\u4e00\u4e0b\u4f1a\u53d1\u73b0\u53d8\u4e3ainit-&gt;ping\u4e86<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/201712070805442.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">setsid<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\"><code>nohup<\/code>\u662f\u901a\u8fc7\u5ffd\u7565SIGHUP\u6765\u4fdd\u6301\u8fd0\u884c\u7684\uff0c\u90a3\u54b1\u80fd\u4e0d\u80fd\u76f4\u63a5\u8ba9<code>ping<\/code>\u4e0d\u5c5e\u4e8e\u5f53\u524d\u4f1a\u8bdd\uff0c\u81ea\u7136\u4e5f\u5c31\u6536\u4e0d\u5230\u5173\u95ed\u7ec8\u7aef\u65f6\u7ed9\u8fdb\u7a0b\u7ec4\u53d1\u7684SIGHUP\u4e86\uff1f\u80fd\u554a\u600e\u4e48\u4e0d\u80fd\u5462\uff0c<code>setsid<\/code>\u554a\uff0c\u7528\u4f8b\u5982\u4e0b\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">setsid ping z.cn\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u6b64\u65f6<code>pstree<\/code>\u548c\u4e0a\u9762\u662f\u4e00\u6837\u7684\uff0c<code>ps<\/code>\u80fd\u591f\u770b\u5230\u4ed6\u7684\u7236\u8fdb\u7a0b\u662finit\uff0c\uff08init\uff1a\u6211\u5c31\u662f\u4e07\u5e74\u5907\u80ce\uff0c\u4e13\u95e8\u6536\u5783\u573e\uff09<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708054548.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">disown<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u5982\u679c\u4e00\u4e0d\u5c0f\u5fc3\u7a0b\u5e8f\u5df2\u7ecf\u8fd0\u884c\u4e86\uff0c\u90a3\u4e48\u8be5\u600e\u4e48\u8865\u6551\u5462\uff1f<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u7b54\u6848\u662f\u4f7f\u7528<code>disown<\/code>\u6765\u63a7\u5236\u4f5c\u4e1a\uff08jobs\uff09\uff0c\u4e3e\u4f8b\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">sleep 100\r\ndisown -h %1\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u5173\u95ed\u7ec8\u7aef\u4e4b\u540e\u4f9d\u65e7\u4f1a\u6301\u7eed\u8fd0\u884c\uff0c\u53ea\u662f\u4e0d\u80fd\u7528<code>jobs<\/code>\u63a7\u5236\u4e86\uff08\u4f46\u5e94\u8be5\u80fd\u7528\u76d6\u8328\u63a7\u5236\uff09\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u611f\u89c9\u4f3c\u4e4e\u4ee5\u4e0a\u65b9\u6cd5\u90fd\u4e0d\u592a\u597d\uff0c\u8981\u4e48\u67e5\u770b\u8f93\u51fa\u592a\u8d39\u4e8b\uff0c\u8981\u4e48\u7528\u8d77\u6765\u5f88\u522b\u626d\uff0c\u90a3\u6709\u4ec0\u4e48\u66f4\u597d\u7684\u529e\u6cd5\u5417\uff1f\u5f53\u7136\u4e86\uff01<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">screen<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\"><code>screen<\/code>\u662f\u4e2a\u975e\u5e38\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u5927\u6982\u5c31\u662f\u6a21\u62dfVT100\/ANSI\u7684\u7a97\u53e3\u7ba1\u7406\u5668\u3002\u8bf4\u4e0d\u660e\u767d\u4e86\u3002\u53cd\u6b63\u6211\u5927\u6982\u662f\u8fd9\u4e48\u7528\u7684\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">screen -S dl\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u505a\u4e00\u70b9\u4e8b\u60c5\u2026\u2026<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u8981\u56de\u6765\u7684\u65f6\u5019\uff0c<code>screen -r dl<\/code>\u5c31\u56de\u5230\u4e86\u7ec8\u7aef\u5173\u95ed\u4e4b\u524d\u7684\u754c\u9762\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5173\u6389\u7ec8\u7aef\uff0c\u54b1\u80fd\u770b\u5230\u8fdb\u7a0b\u6811\u662finit-&gt;screen-&gt;bash-&gt;ping<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708054725.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u67d0\u5929\u6211\u5199\u4e86\u4e2a\u7a0b\u5e8f<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u67d0\u5929\u6211\u5199\u4e86\u4e2a\u7a0b\u5e8f\uff0c\u60f3\u8ba9\u5b83\u6c38\u4e0d\u505c\u606f\uff0c\u4e8e\u662f\u4e4e\u6211\u7528\u4e86screen\uff0c\u7136\u540e\u67d0\u4e00\u5929\u8fd9\u4e2a\u7a0b\u5e8f\u629b\u5f02\u5e38\u4e86\uff0c\u7136\u540e\u6211screen\u56de\u53bb\u770b\u4e86\u4e00\u773c\u7ee7\u7eed\u542f\u52a8\uff1b\u67d0\u5929\u670d\u52a1\u5668\u91cd\u542f\u4e86\uff0c\u6211\u8fdb\u53bb\u518dscreen\u2026\u2026\u5468\u800c\u590d\u59cb\uff0c\u8fd9\u4e2a\u7a0b\u5e8f\u540d\u5b57\u53eb\u505a<a href=\"https:\/\/github.com\/BennyThink\/ExpressBot\">ExpressBot<\/a>\uff0c\u70e6\u4e0d\u70e6\u5450\uff01\uff01<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6240\u4ee5\u54b1\u5f97\u8ba9\u8fd9\u4e2a\u7a0b\u5e8f\u6210\u4e3a\u670d\u52a1\u3002\u987a\u4fbf\u8bf4\u4e00\u53e5\uff0c\u6bd4\u5982\u8bf4\u4f60\u8981\u662f\u5b98\u65b9\u4e8c\u8fdb\u5236\u7684MongoDB\u3001MySQL\uff0c\u90a3\u4e48\u7528systemd\u6216\u8005supervisor\u5b88\u62a4\u4e0b\u4e5f\u662f\u975e\u5e38\u597d\u7684\u9009\u62e9\u3002<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u4f7f\u7528systemd<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">systemd\u662fLinux\u4e0b\u6700\u6d41\u884c\u7684init\uff0c\u7531Lennart Poettering\u5e26\u5934\u5f00\u53d1\u3002\u53d1\u97f3\u4e0d\u662fsystem d\uff0c\u800c\u662fSystem Five Hundred \u56e0\u4e3aD\u662f\u7f57\u9a6c\u6570\u5b57\u91cc\u7684500.<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">Lennart\uff1a<a href=\"https:\/\/linux.cn\/article-3978-1.html\">\u6211\u5c31\u662f\u60f3\u603c\u4f60\u4eec\u7684\u6559\u7687<\/a>\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">\u547d\u4ee4\u6982\u8ff0<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u5173\u4e8esystemd\uff0cArch Linux\u6709\u4e00\u7bc7\u5199\u7684<a href=\"https:\/\/wiki.archlinux.org\/index.php\/systemd_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)\">\u975e\u5e38\u8be6\u5c3d\u7684wiki<\/a>\uff0c\u6211\u4eec\u8981\u60f3\u7ed9\u81ea\u5df1\u7684\u7a0b\u5e8f\u505a\u6210\u670d\u52a1\uff0c\u901a\u5e38\u662f\u8981\u6dfb\u52a0\u5355\u5143\uff08unit\uff09\uff0c\u5355\u5143\u53ef\u4ee5\u662f\u7cfb\u7edf\u670d\u52a1\uff08.service\uff09\u3001\u6302\u8f7d\u70b9\uff08.mount\uff09\u3001sockets\uff08.sockets\uff09 \u3001\u7cfb\u7edf\u8bbe\u5907\uff08.device\uff09\u3001\u4ea4\u6362\u5206\u533a\uff08.swap\uff09\u3001\u6587\u4ef6\u8def\u5f84\uff08.path\uff09\u3001\u542f\u52a8\u76ee\u6807\uff08.target\uff09\u3001\u7531 systemd \u7ba1\u7406\u7684\u8ba1\u65f6\u5668\uff08.timer\uff09\u3002\u5982\u679c\u6ca1\u6709\u6269\u5c55\u540d\uff0c\u90a3\u4e48\u5c31\u4f1a\u88ab\u5f53\u4f5c\u670d\u52a1\uff0c\u6bd4\u5982\u8bf4sshd\u548csshd.service\u5c31\u662f\u4e00\u4e2a\u610f\u601d\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">system\u7684\u4e3b\u8981\u547d\u4ee4\u662f<code>systemctl<\/code>\uff0c\u5e38\u7528\u7684\u670d\u52a1\u76f8\u5173\u547d\u4ee4\u6709<code>start<\/code>\uff0c<code>stop<\/code>\uff0c<code>restart<\/code>\uff0c<code>reload<\/code>\uff0c<code>status<\/code>\uff0c<code>enable<\/code>\uff0c<code>disable<\/code>\uff0c<code>mask<\/code>\uff08\u7981\u7528\uff09\uff0c<code>unmask<\/code>\uff08\u53d6\u6d88\u7981\u7528\uff09\uff0c<code>daemon-reload<\/code>\uff0c\u4e3e\u4f8b\uff08\u9700\u8981root\u6743\u9650\uff09\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">#\u7acb\u5373\u542f\u52a8\u5355\u5143\uff1a\r\nsystemctl start &lt;\u5355\u5143&gt;\r\n#\u91cd\u65b0\u8f7d\u5165 systemd\uff0c\u626b\u63cf\u65b0\u7684\u6216\u6709\u53d8\u52a8\u7684\u5355\u5143\uff0c\u5728\u4fee\u6539\u4e86\u5355\u5143\u6587\u4ef6\u4e4b\u540e\u662f\u975e\u5e38\u5fc5\u8981\u7684\uff1a\r\nsystemctl daemon-reload\r\n#\u4e00\u4e9b\u5176\u4ed6\u547d\u4ee4\u4e3e\u4f8b\uff1a\r\n# \u91cd\u542f\u7cfb\u7edf\r\nsystemctl reboot\r\n# \u5173\u95ed\u7cfb\u7edf\uff0c\u5207\u65ad\u7535\u6e90\r\nsystemctl poweroff\r\n#\u67e5\u770b\u542f\u52a8\u8017\u65f6\r\nsystemd-analyze\r\n#\u663e\u793a\u67d0\u4e2a Unit \u662f\u5426\u6b63\u5728\u8fd0\u884c(\u4e00\u822c\u7528\u4e8e\u811a\u672c\u5224\u65ad)\r\nsystemctl is-active sshd.service\r\n#\u4fee\u6539\u5355\u5143\r\nsystemctl edit --full sshd.service\r\n<\/pre>\n<h3><span style=\"font-size: 12pt;\">systemd\u5355\u5143\u52a0\u8f7d\u8def\u5f84<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u5355\u5143\u6587\u4ef6\u662f\u6709\u4e00\u5b9a\u7684\u52a0\u8f7d\u987a\u5e8f\u7684\uff0c\u5148\u52a0\u8f7d<code>\/etc\/system\/system<\/code>\uff0c\u7136\u540e\u662f<code>\/run\/systemd\/system<\/code>\uff0c\u6700\u540e\u662f<code>\/lib\/systemd\/system<\/code>\uff0c\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708054810.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">service\u793a\u4f8b\uff1aUnit<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u53ef\u4ee5\u5206\u4e3aunit\u3001service\u3001install \u8fd9\u51e0\u4e2a\u6a21\u5757\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">unit\u5b9a\u4e49\u63cf\u8ff0\u3001\u542f\u52a8\u987a\u5e8f\u3001\u4f9d\u8d56\u7b49\uff0c<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><code>Description<\/code>\u7ed9\u51fa\u5f53\u524d\u670d\u52a1\u7684\u7b80\u5355\u63cf\u8ff0\uff0c<code>Documentation<\/code>\u5b57\u6bb5\u7ed9\u51fa\u6587\u6863\u8def\u5f84\uff1b<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><code>After<\/code>\u548c<code>Before<\/code>\u6307\u5b9a\u542f\u52a8\u987a\u5e8f\uff08\u53ea\u662f\u987a\u5e8f\uff0c\u4e0d\u662f\u4f9d\u8d56\uff09\uff0c\u6bd4\u5982\u8bf4\u5982\u679c\u5728\u7f51\u7edc\u670d\u52a1\u4e4b\u540e\u542f\u52a8\uff0c\u90a3\u4e48\u5c31\u5e94\u8be5\u5199\u6210<\/span><\/p>\n<pre class=\"prettyprint linenums\">After=network.target\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u4f9d\u8d56\u5173\u7cfb\uff0c\u9700\u8981\u4f7f\u7528<code>Wants<\/code>\u548c<code>Requires<\/code><\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><code>Wants<\/code>\u8868\u793a\u4f9d\u8d56\u5173\u7cfb\u662f\u53ef\u9009\u7684\uff1b<code>Requires<\/code>\u4f9d\u8d56\u5173\u7cfb\u662f\u5fc5\u987b\u7684\uff0c\u5982\u679c\u88ab\u4f9d\u8d56\u7684\u670d\u52a1\u542f\u52a8\u5931\u8d25\u6216\u5f02\u5e38\u9000\u51fa\uff0c\u90a3\u4e48\u4f9d\u8d56\u8005\u4e5f\u5fc5\u987b\u9000\u51fa\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">service\u793a\u4f8b\uff1aservice<\/span><\/h3>\n<ul>\n<li><span style=\"font-size: 12pt;\">Exec<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12pt;\">service\u4e2d\u6700\u91cd\u8981\u7684\u5c31\u662f<code>ExecStart<\/code>\uff0c\u5b9a\u4e49\u542f\u52a8\u8fdb\u7a0b\u65f6\u6267\u884c\u7684\u547d\u4ee4\uff0c\u9700\u8981\u4f7f\u7528\u7edd\u5bf9\u8def\u5f84\uff0c\u7c7b\u4f3c\u7684\u8fd8\u6709<code>ExecReload<\/code>\uff08\u91cd\u542f\u670d\u52a1\u65f6\u6267\u884c\uff09\u3001<code>ExecStop<\/code>\uff08\u505c\u6b62\u670d\u52a1\u65f6\u6267\u884c\uff09\u3001<code>ExecStartPre<\/code>\uff08\u542f\u52a8\u670d\u52a1\u4e4b\u524d\u6267\u884c\uff09\u3001<code>ExecStartPost<\/code>\uff08\u542f\u52a8\u670d\u52a1\u4e4b\u540e\u6267\u884c\uff09\u3001<code>ExecStopPost<\/code>\uff08\u505c\u6b62\u670d\u52a1\u4e4b\u540e\u6267\u884c\uff09<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 12pt;\">Type<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12pt;\">Type\u5b9a\u4e49\u542f\u52a8\u7c7b\u578b\uff0c\u6709\u597d\u591a\u79cd\uff0c\u6bd4\u5982\u8bf4<code>simple<\/code>\u3001<code>forking<\/code>\u3001<code>oneshot<\/code>\u2026\u2026<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u54b1\u4e00\u822c\u7528<code>simple<\/code>\u6bd4\u8f83\u591a\uff0c\u610f\u601d\u662f<code>ExecStart<\/code>\u5b57\u6bb5\u542f\u52a8\u7684\u8fdb\u7a0b\u4e3a\u4e3b\u8fdb\u7a0b\u3002<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 12pt;\">KillMode<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12pt;\">KillMode\uff1a\u5b9a\u4e49 \u5982\u4f55\u505c\u6b62\u670d\u52a1\uff0c\u6709<code>control-group\u3001process\u3001mixed\u3001none<\/code><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">control-group\uff08\u9ed8\u8ba4\u503c\uff09\uff1a\u5f53\u524d\u63a7\u5236\u7ec4\u91cc\u9762\u7684\u6240\u6709\u5b50\u8fdb\u7a0b\uff0c\u90fd\u4f1a\u88ab\u6740\u6389<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">process\uff1a\u53ea\u6740\u4e3b\u8fdb\u7a0b\uff0c\u4f1a\u8bdd\u4fdd\u7559<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">mixed\uff1a\u4e3b\u8fdb\u7a0b\u5c06\u6536\u5230 SIGTERM \u4fe1\u53f7\uff0c\u5b50\u8fdb\u7a0b\u6536\u5230 SIGKILL \u4fe1\u53f7<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">none\uff1a\u6ca1\u6709\u8fdb\u7a0b\u4f1a\u88ab\u6740\u6389\uff0c\u53ea\u662f\u6267\u884c\u670d\u52a1\u7684 stop \u547d\u4ee4\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6211\u4eec\u6765\u770b\u4e0bsshd\u7684\u914d\u7f6e\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708054918.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u77e5\u9053\u4e3a\u4ec0\u4e48sshd\u670d\u52a1\u5173\u4e86\uff0c\u5f53\u524d\u8fde\u63a5\u8fd8\u4e0d\u65ad\u5427\u3002<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 12pt;\">Restart<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12pt;\">Restart\u5b9a\u4e49\u91cd\u542f\u5b57\u6bb5\uff0c\u6709\u8fd9\u4e48\u51e0\u4e2a\u503c\uff1a<code>on\u3001always\u3001on-success\u3001on-failure\u3001on-abnormal\u3001on-abort\u3001on-watching<\/code>\uff0c\u5177\u4f53\u8be6\u60c5\u5982\u4e0b\u8868\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708055089.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u8fd8\u6709\u4e00\u4e2a<code>RestartSec<\/code>\uff0c\u6307\u7684\u662f\u91cd\u542f\u670d\u52a1\u4e4b\u524d\u7b49\u5f85\u51e0\u79d2\u3002<\/span><\/p>\n<ul>\n<li><span style=\"font-size: 12pt;\">Environment<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 12pt;\"><code>Environment<\/code>\u5b9a\u4e49\u73af\u5883\u53d8\u91cf\u3002\u4e00\u4e2a\u6bd4\u8f83\u5751\u7684\u5730\u65b9\u662fsystemd\u65e0\u6cd5\u8bfb\u53d6<code>\/etc\/profile<\/code>,<code>.bashrc<\/code>\u7b49\u73af\u5883\u53d8\u91cf\uff0csystemd\u542f\u52a8\u7684\u670d\u52a1\u4e5f\u8bfb\u53d6\u4e0d\u5230\u8fd9\u4e9b\u73af\u5883\u53d8\u91cf\uff08\u77e5\u9053\u4e3a\u5565\u7528\u7edd\u5bf9\u8def\u5f84\u4e86\u5427\uff09\uff0c\u6709\u8fd9\u4e48\u51e0\u79cd\u89e3\u51b3\u65b9\u6848\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">1.\u4fee\u6539systemd\u914d\u7f6e\u6587\u4ef6\uff0c\u4f7f\u5f97\u73af\u5883\u53d8\u91cf\u5728\u6240\u6709\u5355\u5143\u4e2d\u53ef\u89c1<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5728<code> \/etc\/systemd\/user.conf<\/code>\u6587\u4ef6\u4e2d\u4f7f\u7528 <code>DefaultEnvironment <\/code>\u9009\u9879\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">2.\u4fee\u6539\u5355\u5143\u914d\u7f6e\u6587\u4ef6\uff0c\u4f7f\u5f97\u73af\u5883\u53d8\u91cf\u5728\u7528\u6237\u5355\u5143\u4e2d\u53ef\u89c1<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><code>systemctl edit --full expressbot.service<\/code>\uff08\u6216\u8005\u627e\u5230\u5bf9\u5e94\u7684\u6587\u4ef6\u8def\u5f84\uff0c\u6bd4\u5982\u8bf4<code>\/lib\/system\/system\/expressbot.service<\/code>\uff09 \u4e0b\u589e\u52a0\u914d\u7f6e\u6587\u4ef6\u8bbe\u7f6e\u3002<\/span><\/p>\n<ol>\n<li><span style=\"font-size: 12pt;\">\u5bfc\u5165\u53d8\u91cf<\/span><\/li>\n<\/ol>\n<p><span style=\"font-size: 12pt;\">\u5728\u4efb\u4f55\u65f6\u5019\uff0c \u4f7f\u7528 <code>systemctl --user set-environment<\/code> \u6216<code> systemctl --user import-environment<\/code>. \u5bf9\u8bbe\u7f6e\u4e4b\u540e\u542f\u52a8\u7684\u6240\u6709\u7528\u6237\u5355\u5143\u6709\u6548\uff0c\u4f46\u5df2\u7ecf\u542f\u52a8\u7684\u7528\u6237\u5355\u5143\u4e0d\u4f1a\u751f\u6548\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u4f8b\u5b50\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">[Service]\r\nEnvironment=&quot;TOKEN=12345&quot;\r\nEnvironment=&quot;DB_PATH=\/home\/ExpressBot\/expressbot\/bot.db&quot;\r\nEnvironment=&quot;TURING_KEY=111111&quot;\r\nEnvironment=&quot;DEBUG=0&quot;\r\n\r\nRestart=always\r\nType=simple\r\nExecStart=\/usr\/bin\/python \/home\/ExpressBot\/expressbot\/main.py\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u6b64\u65f6\u5728\u8fd9\u4e2apython\u811a\u672c\u4e2d\u5c31\u53ef\u4ee5\u7528<code>os.environ.get('DEBUG')<\/code>\u6765\u83b7\u53d6\u5230\u73af\u5883\u53d8\u91cf\u5566\uff08\u7c7b\u578b\u5168\u90e8\u4e3a\u5b57\u7b26\u4e32\uff09\u3002\u5176\u5b9e\u8fd9\u79cd\u65b9\u5f0f\u4e5f\u65b9\u4fbf\u66f4\u65b0\uff0c\u4e0d\u7528\u518dmerge\u4e86\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">service\u793a\u4f8b\uff1ainstall<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\"><code>install<\/code>\u5c31\u6bd4\u8f83\u7b80\u5355\u4e86\uff0c\u5c31\u662f\u5b9a\u4e49\u4ec0\u4e48\u60c5\u51b5\u4e0b\u542f\u52a8\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6bd4\u5982\u8bf4<code>WantedBy=multi-user.target<\/code>\u5c31\u610f\u5473\u7740\u5728\u591a\u7528\u6237\u73af\u5883\u4e0b\u4f1a\u542f\u52a8\uff0c<code>WantedBy= graphical.target<\/code>\u8868\u793a\u56fe\u5f62\u7528\u6237\u4e0b\u542f\u52a8\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">\u5b8c\u6574\u914d\u7f6e\u6587\u4ef6\uff1a<\/span><\/h3>\n<pre class=\"prettyprint linenums\">[Unit]\r\nDescription=A Telegram Bot for querying expresses\r\nAfter=network.target network-online.target nss-lookup.target\r\n\r\n[Service]\r\nEnvironment=&quot;TOKEN=12345&quot;\r\nEnvironment=&quot;DB_PATH=\/home\/ExpressBot\/expressbot\/bot.db&quot;\r\nEnvironment=&quot;TURING_KEY=111111&quot;\r\nEnvironment=&quot;DEBUG=0&quot;\r\nRestart=always\r\nType=simple\r\nExecStart=\/usr\/bin\/python \/home\/ExpressBot\/expressbot\/main.py\r\n\r\n[Install]\r\nWantedBy=multi-user.target\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u66f4\u591a\u8be6\u60c5\u53ef\u4ee5<a href=\"http:\/\/www.ruanyifeng.com\/blog\/2016\/03\/systemd-tutorial-part-two.html\">\u53c2\u8003\u8fd9\u91cc<\/a><\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">\u4e0d\u597d\u73a9\u7684\u8f6e\u5b50<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u5728\u4ee5\u524d\uff0c\u6211\u662f\u600e\u4e48\u68c0\u6d4b\u670d\u52a1\u662f\u5426\u8fd8\u5728\u8fd0\u884c\u7684\u5462\u2026\u2026<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u57fa\u672c\u601d\u8def\u662f\uff0c<code>pidof<\/code>\u80fd\u83b7\u53d6\u5230\u8fd0\u884c\u4e2d\u7684\u8fdb\u7a0b\u7684id\uff0c\u7136\u540e\u6839\u636e<code>$?<\/code>\u5224\u65ad\u662f\u5426\u8fd8\u5728\u8fd0\u884c\uff0c\u6bd4\u5982\u8bf4\u2026\u2026<\/span><\/p>\n<pre class=\"prettyprint linenums\">pidof php-fpm &gt;\/dev\/null\r\nif [ $? -eq 0 ] ; then\r\n    echo &quot;It is running.&quot;\r\nelse\r\n    echo &quot;At `date` PHP Server was stopped&quot;&gt;&gt; \/home\/wwwlogs\/service_log\r\nfi\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u7136\u540e\u52a0\u5165\u5230crontab\u4e2d\uff08\u503c\u5f97\u4e00\u63d0\u7684\u662f\uff0csystemd\u4e5f\u6709\u4e2atimer\uff0c\u7c7b\u4f3c\u4e8ecrontab\uff0c\u53ef\u4ee5\u53c2\u8003<a href=\"https:\/\/wiki.archlinux.org\/index.php\/Systemd\/Timers_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&quot; \\l &quot;.E6.9B.BF.E4.BB.A3_cron\">Arch<\/a> <a href=\"https:\/\/wiki.archlinux.org\/index.php\/Systemd\/Timers_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&quot; \\l &quot;.E6.9B.BF.E4.BB.A3_cron\">L<\/a><a href=\"https:\/\/wiki.archlinux.org\/index.php\/Systemd\/Timers_(%E7%AE%80%E4%BD%93%E4%B8%AD%E6%96%87)&quot; \\l &quot;.E6.9B.BF.E4.BB.A3_cron\">inux<\/a>\uff09\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u8fd9\u6837\u505a\u5176\u5b9e\u4e0d\u662f\u5f88\u7406\u60f3\uff0c\u6700\u957f\u53ef\u80fd\u4f1a\u5bfc\u81f4\u670d\u52a1\u4e2d\u65ad\u8fd1\u4e00\u5206\u949f\uff0c\u8fd9\u7edd\u5bf9\u662f\u83b1\u6d1b\u4e09\u89d2\u5f62\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6240\u4ee5\uff0c\u76f4\u63a5\u7ed9Restart\u5b57\u6bb5\u4e00\u4e2a<code>on-abnormal<\/code>\u6216\u8005<code>on-failure<\/code>\u5c31\u597d\u4e86\u561b\u3002<\/span><br \/>\n<div id=\"sc_blue\"><span style=\"font-size: 12pt;\">\u601d\u8003\u4e00\u4e0b\uff1acron\u6700\u77ed\u65f6\u95f4\u5468\u671f\u662f\u4e00\u5206\u949f\u4e00\u6b21\uff0c\u6211\u5c31\u60f3\u5341\u79d2\u949f\u4e00\u6b21\uff0c\u8be5\u600e\u4e48\u529e\uff1f<\/span><\/div><\/p>\n<h2><span style=\"font-size: 12pt;\">systemd\u7684\u4f18\u7f3a\u70b9<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">systemd\u7684\u529f\u80fd\u5341\u5206\u5f3a\u5927\uff0c\u914d\u7f6e\u6587\u4ef6\u4e5f\u597d\u5199\uff0c\u800c\u4e14systemd\u6bd4\u8f83\u7a33\u5b9a\uff08\u5b83\u8981\u662f\u6302\u4e86\uff0c\u90a3\u7cfb\u7edf\u5c31\u6302\u4e86\uff09\u3002\u4f46\u662f\u6709\u4e00\u70b9\u53ef\u80fd\u4e0d\u592a\u597d\uff0c\u5c31\u662f\u5e76\u4e0d\u662f\u6240\u6709\u7cfb\u7edf\u7684init\u90fd\u662fsystemd\uff08systemd\u4e89\u8bae\u6709\u70b9\u5927\uff09\uff0c\u6bd4\u5982\u8bf4Ubuntu 14.04\u5c31\u4e0d\u662f\uff0816.04\u662f\uff0c\u8ddf\u4e0a\u6e38Debian\uff09\uff0cDevuan\uff08\u4e00\u4e2a\u4e0d\u7528systemd\u7684Debian\uff09\u3002\u54e6\u5bf9\u4e86\uff0csystemd\u770b\u65e5\u5fd7\u611f\u89c9\u4e0d\u662f\u90a3\u4e48\u65b9\u4fbf<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u53e6\u4e00\u4e2a\u5907\u9009\u65b9\u6848\u662fsupervisor\uff0cpython\u54b1\u90fd\u6709\u5427\u2026\u2026<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">Supervisor<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">Supervisor \u662f\u4e00\u4e2a\u7528 Python \u5199\u7684\u8fdb\u7a0b\u7ba1\u7406\u5de5\u5177\uff0c\u53ef\u4ee5\u5f88\u65b9\u4fbf\u7684\u7528\u6765\u542f\u52a8\u3001\u91cd\u542f\u3001\u5173\u95ed\u8fdb\u7a0b\uff08\u4e0d\u4ec5\u4ec5\u662f Python \u8fdb\u7a0b\uff09\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5148\u7528pip\u5b89\u88c5:<\/span><\/p>\n<pre class=\"prettyprint linenums\">pip install supervisor\r\n<\/pre>\n<h3><span style=\"font-size: 12pt;\">\u914d\u7f6esupervisord<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u540c\u6837\uff0csupervisor\u4e5f\u6709\u4e00\u4e2a\u914d\u7f6e\u6587\u4ef6\u4f18\u5148\u8def\u5f84\uff0c<code>$CWD\/supervisord.conf<\/code> &gt; <code>$CWD\/etc\/supervisord.conf<\/code> &gt; <code>\/etc\/supervisord.conf<\/code>\uff0c<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6211\u4e00\u822c\u4f1a\u521b\u5efa\u4e00\u4e2a<code>\/etc\/supervisord.conf<\/code>\uff0c\u7136\u540e\u521b\u5efa\u4e00\u4e2a<code>\/etc\/supervisor\/SomeService.conf<\/code>,\u7136\u540e\u5728<code>\/etc\/supervisord.conf<\/code>\u4e2d\u5305\u542b\u540e\u8005\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u5982\u4e0b\u521b\u5efa\u9ed8\u8ba4\u914d\u7f6e\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">echo_supervisord_conf &gt; \/etc\/supervisord.conf\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u6700\u540e\u4e00\u884c\u5305\u542b\u914d\u7f6e\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">[include]\r\nfiles = \/etc\/supervisor\/*.conf\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u7136\u540e\u521b\u5efa\u5982\u4e0b\u201c\u5355\u5143\u201d\uff1a<\/span><\/p>\n<pre class=\"prettyprint linenums\">[program:expressbot]\r\ndirectory = \/home\/ExpressBot\/expressbot\/main.py\r\ncommand = \/usr\/bin\/python \/home\/ExpressBot\/expressbot\/main.py\r\nautostart = true ; \u5728 supervisord \u542f\u52a8\u7684\u65f6\u5019\u4e5f\u81ea\u52a8\u542f\u52a8\r\nstartsecs = 5 ; \u542f\u52a8 5 \u79d2\u540e\u6ca1\u6709\u5f02\u5e38\u9000\u51fa\uff0c\u5c31\u5f53\u4f5c\u5df2\u7ecf\u6b63\u5e38\u542f\u52a8\u4e86\r\nautorestart = true ; \u7a0b\u5e8f\u5f02\u5e38\u9000\u51fa\u540e\u81ea\u52a8\u91cd\u542f\r\nstartretries = 3 ; \u542f\u52a8\u5931\u8d25\u81ea\u52a8\u91cd\u8bd5\u6b21\u6570\uff0c\u9ed8\u8ba4\u662f 3\r\nuser = root ; \u7528\u54ea\u4e2a\u7528\u6237\u542f\u52a8\r\nredirect_stderr = true ; \u628a stderr \u91cd\u5b9a\u5411\u5230 stdout\uff0c\u9ed8\u8ba4 false\r\nstdout_logfile_maxbytes = 20MB ; stdout \u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff0c\u9ed8\u8ba4 50MB\r\nstdout_logfile_backups = 20 ; stdout \u65e5\u5fd7\u6587\u4ef6\u5907\u4efd\u6570\r\nstdout_logfile = \/var\/log\/expressbot_stdout.log ;\u65e5\u5fd7\u6587\u4ef6\r\n<\/pre>\n<p><span style=\"font-size: 12pt;\">\u7136\u540e\u8fd0\u884csupervisord\u5c31\u53ef\u4ee5\u542f\u52a8supervisor\u5566\u3002<\/span><\/p>\n<h3><span style=\"font-size: 12pt;\">\u63a7\u5236supervisor<\/span><\/h3>\n<p><span style=\"font-size: 12pt;\">\u7c7b\u4f3csystemd\uff0csupervisor\u4e5f\u6709\u4e2a<code>supervictl<\/code>\uff08\u914d\u7f6e\u6587\u4ef6\u67e5\u627e\u987a\u5e8f\u4e0esupervisord\u4e00\u6837\uff09\uff0c\u76f4\u63a5\u8f93\u5165\u4f1a\u8fdb\u5165\u4ea4\u4e92\u6a21\u5f0f\uff0c\u547d\u4ee4\u4e3b\u8981\u6709\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">status\u3001stop\u3001restart\u3001reread\uff08\u8bfb\u53d6\u6709\u66f4\u65b0\u65b0\u589e\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u4e0d\u4f1a\u542f\u52a8\u65b0\u6dfb\u52a0\u7684\u7a0b\u5e8f\uff09\u3001update\uff08\u91cd\u542f\u914d\u7f6e\u6587\u4ef6\u4fee\u6539\u8fc7\u7684\u7a0b\u5e8f\uff09\uff0c\u793a\u4f8b\uff1a<\/span><\/p>\n<p><span style=\"font-size: 12pt;\"><img decoding=\"async\" src=\"https:\/\/7bc5d24.webp.ee\/wp-content\/uploads\/2017\/12\/2017120708055254.png\" alt=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" title=\"Linux\u600e\u4e48\u8ba9\u7a0b\u5e8f\u6301\u7eed\u8fd0\u884c\uff1a\u7b80\u5355\u8bf4\u8bf4\u51e0\u79cd\u597d\u73a9\u7684\u529e\u6cd5\" \/><\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6216\u8005\u76f4\u63a5\u5728bash\u4e0b<code>supervisorctl restart WebTerminal<\/code>\u4e5f\u662f\u53ef\u4ee5\u7684\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6ce8\u610f\uff1a\u6709\u7684\u65f6\u5019\u66f4\u65b0\u914d\u7f6e\u6587\u4ef6\u4f1a\u6ca1\u7528\uff0c\u6b64\u65f6\u5c31\u8981<code>supervisorctl reload<\/code>\u5566\u3002<\/span><\/p>\n<h2><span style=\"font-size: 12pt;\">supervisor\u4f18\u7f3a\u70b9<\/span><\/h2>\n<p><span style=\"font-size: 12pt;\">\u76f8\u6bd4systemd\uff0csupervisor\u7684\u7279\u70b9\u662f\u7cbe\u51c6\u3001\u5c0f\u800c\u5168\uff0c\u6bd5\u7adfsystemd\u662f\u5927\u7ba1\u5bb6\u561b\uff1bsupervisor\u8de8\u5e73\u53f0\uff0c\u4e0d\u53d7init\u7684\u9650\u5236\uff1bsupervisor\u63d0\u4f9b\u4e00\u4e2aWeb\u9875\u9762\uff0c\u4f7f\u7528\u7528\u6237\u540d\u5bc6\u7801\u7684\u57fa\u672c\u8eab\u4efd\u9a8c\u8bc1\uff08\u5728<code>\/etc\/supervisord.conf<\/code>\u4e2d\u914d\u7f6e\uff09\u3002<\/span><\/p>\n<p><span style=\"font-size: 12pt;\">\u6700\u5927\u7684\u7f3a\u70b9\u5c31\u662f\uff0c\u4e07\u4e00\u6211\u624b\u6b8bkill\u4e86supervisord\uff0c\u90a3\u4e5f\u5c31\u5b8c\u86cb\u5566~\u53ef\u662f\u6211\u8981\u662fkill\u4e86init\u5462\u2026\u2026\u6ca1\u7528\u7684\uff0c\u4f60\u6740\u4e0d\u6389\u7684\u3002<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fd9\u7bc7\u6587\u7ae0\u5728 2017\u5e7412\u670817\u65e521:44:36 \u66f4\u65b0\u4e86\u54e6~\u8fd9\u6bb5\u65f6\u95f4\uff0c\u6709\u5c0f\u4f19\u4f34\u95ee\u6211\uff0c\u600e\u4e48\u80fd\u8ba9\u7a0b\u5e8f\u5728\u5173\u6389ssh [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-3315","post","type-post","status-publish","format-standard","hentry","category-linux"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/3315","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/comments?post=3315"}],"version-history":[{"count":0,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/posts\/3315\/revisions"}],"wp:attachment":[{"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/media?parent=3315"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/categories?post=3315"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dmesg.app\/wp-json\/wp\/v2\/tags?post=3315"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}