{"id":95,"date":"2023-03-07T14:06:59","date_gmt":"2023-03-07T06:06:59","guid":{"rendered":"http:\/\/192.168.1.15:89\/?p=95"},"modified":"2025-05-04T20:04:54","modified_gmt":"2025-05-04T12:04:54","slug":"systemctl","status":"publish","type":"post","link":"https:\/\/www.skyblogs.xyz\/index.php\/2023-03-07\/systemctl\/","title":{"rendered":"linux\u6dfb\u52a0\u5f00\u673a\u81ea\u542f\u7a0b\u5e8f"},"content":{"rendered":"<p>\u524d\u8a00\uff1a<\/p>\n<p>\u660e\u660e\u7ecf\u5e38\u7528\u5230\u7684\u4e1c\u897f\u5374\u8fd8\u662f\u5fd8\u8bb0\u5177\u4f53\u5185\u5bb9\uff0c\u4e8e\u662f\u5199\u4e00\u7bc7\u6587\u7ae0\u6765\u8bb0\u5f55\u4e00\u4e0b<\/p>\n<p>\u6743\u4e14\u5f53\u4e2a\u526f\u672c\u4e86\u3002<\/p>\n<h2>\u539f\u7406\u7b80\u4ecb<\/h2>\n<p>\u5148\u521b\u5efa\u4e00\u4e2a\u8fdb\u7a0b\u6587\u4ef6\uff0c\u518d\u901a\u8fc7systemctl\u547d\u4ee4\u8f7d\u5165\uff0c\u4ece\u800c\u5b9e\u73b0\u7a0b\u5e8f\u5230\u53ef\u63a7\u8fdb\u7a0b\u7684\u8f6c\u53d8<\/p>\n<p>\u4f46\u662f\u5bf9\u4e8e\u67d0\u4e9b\u9700\u8981\u7ecf\u5e38\u770b\u547d\u4ee4\u8fd4\u56de\u65e5\u5fd7\u7684\u5e94\u7528\uff0ctmux\u548cscreen\u5e94\u8be5\u6bd4systemctl\u8981\u66f4\u52a0\u9002\u5408\uff08\u5bf9\uff0c\u6ca1\u9519\u3002\u5c31\u662f\u8bf4\u4f60Minecraft\uff09<\/p>\n<h2>\u914d\u7f6e\u8fdb\u7a0b<\/h2>\n<h3>1.\u521b\u5efa\u670d\u52a1\u6587\u4ef6<\/h3>\n<p>\u8f93\u5165\u547d\u4ee4<code>vim \/etc\/systemd\/system\/xxx.service<\/code>\u6765\u521b\u5efa\u8fdb\u7a0b\u6587\u4ef6.\u6587\u4ef6\u540d\u81ea\u5b9a\u4e49,\u53ea\u8981\u4ee5.service\u7ed3\u5c3e\u5373\u53ef<br \/>\n\u63a5\u7740\u6309<code>i<\/code>\u8fdb\u5165\u7f16\u8f91\u6a21\u5f0f,\u8f93\u5165\u4ee5\u4e0b\u5185\u5bb9:<\/p>\n<pre class=\"prettyprint linenums\" >[Unit] \r\nDescription=my application \r\n#\u8fdb\u7a0b\u5907\u6ce8 \r\nAfter=network.target syslog.target \r\n#\u81ea\u542f\u65f6\u5728\u54ea\u4e2a\u670d\u52a1\u540e\u542f\u7528\u672c\u8fdb\u7a0b \r\nWants=network.target \r\n#\u8be5\u8fdb\u7a0b\u6240\u4f9d\u8d56\u7684\u670d\u52a1,\u53ea\u6709\u5f53\u4f9d\u8d56\u670d\u52a1\u6b63\u5e38\u8fd0\u884c\u65f6\u624d\u4f1a\u542f\u7528\u672c\u8fdb\u7a0b \r\n\r\n[Service] \r\nType=simple \r\n#\u8fdb\u7a0b\u7c7b\u578b \u53ef\u586bsimple\uff0cexec\uff0cforking\uff0coneshot\uff0cdbus\uff0cnotify\uff0cidle\u7b49.\u8fd9\u91cc\u586b\u9ed8\u8ba4\u5373\u53ef \r\nExecStart=\/home\/a.sh \r\n#\u5e94\u7528\u7684\u542f\u52a8\u547d\u4ee4\r\nRestart=always \r\n#\u662f\u5426\u5728\u8fdb\u7a0b\u9000\u51fa\u540e\u81ea\u52a8\u91cd\u542f\u8fdb\u7a0b\r\nRestartSec=1 \r\n#\u91cd\u542f\u95f4\u9694\r\n\r\n[Install] \r\nWantedBy=multi-user.target \r\n#\u8868\u793a\u8be5\u8fdb\u7a0b\u6240\u5728\u7684\u670d\u52a1\u7ec4<\/pre>\n<p>\u4e4b\u540e\u518d\u901a\u8fc7<code>ESC<\/code>\u548c<code>:wq<\/code>\u6765\u9000\u51fa\u4fdd\u5b58\u5373\u53ef<\/p>\n<h3>2.\u542f\u7528\u8fdb\u7a0b<\/h3>\n<p>\u5728\u6587\u4ef6\u521b\u5efa\u5b8c\u6210\u4e4b\u540e,\u5148\u901a\u8fc7<code>systemctl daemon-reload<\/code>\u6765\u5237\u65b0systemctl\u7684\u7f13\u5b58 \u518d\u901a\u8fc7systemctl\u547d\u4ee4\u6765\u7ba1\u7406\u4f60\u7684\u8fdb\u7a0b,\u5982:<\/p>\n<pre class=\"prettyprint linenums\" >systemctl start xxx #\u5f00\u542f\u8fdb\u7a0b \r\nsystemctl restart xxx #\u91cd\u542f\u8fdb\u7a0b \r\nsystemctl stop xxx #\u505c\u6b62\u8fdb\u7a0b \r\nsystemctl status xxx #\u67e5\u770b\u8fdb\u7a0b\u72b6\u6001 \r\nsystemctl enable xxx #\u542f\u7528\u8fdb\u7a0b\u5f00\u673a\u81ea\u542f \r\nsystemctl disable xxx #\u7981\u7528\u8fdb\u7a0b\u5f00\u673a\u81ea\u542f #\u5176\u4e2dxxx\u4e3a\u4f60\u521b\u5efa\u8fdb\u7a0b\u6587\u4ef6\u65f6\u7684\u6587\u4ef6\u540d,\u540e\u9762\u7684.service\u540e\u7f00\u5728\u901a\u8fc7systemctl\u547d\u4ee4\u8c03\u7528\u65f6\u53ef\u7701\u7565<\/pre>\n<p>\u4ee5\u4e0a\u4fbf\u662f\u5728linux\u4e0b\u521b\u5efa\u81ea\u542f\u52a8\u8fdb\u7a0b\u7684\u57fa\u672c\u6d41\u7a0b,\u56e0\u672c\u7bc7\u53ea\u4f5c\u7b14\u8bb0,\u82e5\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u8be6\u7ec6\u53ca\u539f\u7406\u65b9\u9762\u7684\u5185\u5bb9<\/p>\n<p>\u53ef\u524d\u5f80<a href=\"https:\/\/www.cnblogs.com\/jhxxb\/p\/10654554.html\">https:\/\/www.cnblogs.com\/jhxxb\/p\/10654554.html<\/a>\u53bb\u6df1\u5165\u4e86\u89e3systemctl\u7684\u76f8\u5173\u673a\u5236.<\/p>\n<h3><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-96 aligncenter\"  src=\"https:\/\/www.skyblogs.xyz\/wp-content\/themes\/lolimeow-lolimeowV13.13\/assets\/images\/loading.gif\" data-src=\"http:\/\/www.skyblogs.xyz\/wp-content\/uploads\/2023\/03\/systemctl-172x300.png\" class=\"lazy\" loading=\"lazy\" alt=\"systemctl\" srcset=\"https:\/\/www.skyblogs.xyz\/wp-content\/uploads\/2023\/03\/systemctl-172x300.png 172w, https:\/\/www.skyblogs.xyz\/wp-content\/uploads\/2023\/03\/systemctl-586x1024.png 586w, https:\/\/www.skyblogs.xyz\/wp-content\/uploads\/2023\/03\/systemctl.png 717w\" sizes=\"(max-width: 363px) 100vw, 363px\" \/><\/h3>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u8a00\uff1a \u660e\u660e\u7ecf\u5e38\u7528\u5230\u7684\u4e1c\u897f\u5374\u8fd8\u662f\u5fd8\u8bb0\u5177\u4f53\u5185\u5bb9\uff0c\u4e8e\u662f\u5199\u4e00\u7bc7\u6587\u7ae0\u6765\u8bb0\u5f55\u4e00\u4e0b \u6743\u4e14\u5f53\u4e2a\u526f\u672c\u4e86\u3002 \u539f\u7406\u7b80\u4ecb \u5148\u521b\u5efa\u4e00\u4e2a\u8fdb\u7a0b\u6587\u4ef6\uff0c\u518d\u901a\u8fc7systemctl\u547d\u4ee4\u8f7d\u5165\uff0c\u4ece\u800c\u5b9e\u73b0\u7a0b\u5e8f\u5230\u53ef\u63a7\u8fdb\u7a0b\u7684\u8f6c\u53d8 \u4f46\u662f\u5bf9\u4e8e\u67d0\u4e9b\u9700\u8981\u7ecf\u5e38\u770b\u547d\u4ee4\u8fd4\u56de\u65e5\u5fd7\u7684\u5e94\u7528\uff0ctmux\u548cscreen\u5e94\u8be5\u6bd4systemctl\u8981\u66f4\u52a0\u9002\u5408\uff08\u5bf9\uff0c\u6ca1\u9519\u3002\u5c31\u662f\u8bf4\u4f60Minecraft\uff09 \u914d\u7f6e\u8fdb\u7a0b 1.\u521b\u5efa\u670d\u52a1\u6587\u4ef6 \u8f93\u5165\u547d\u4ee4vim \/etc\/systemd\/sys [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":96,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"\u901a\u8fc7systemctl\u547d\u4ee4\u6765\u5b9e\u73b0linux\u8fdb\u7a0b\u7684\u5f00\u673a\u81ea\u542f %%post_excerpt%%","_seopress_robots_index":"","footnotes":""},"categories":[6],"tags":[20,19,22,21],"class_list":["post-95","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-teck-discussion","tag-linux","tag-systemctl","tag-22","tag-21"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":13,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":297,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/posts\/95\/revisions\/297"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/media\/96"}],"wp:attachment":[{"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyblogs.xyz\/index.php\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}