{"id":917,"date":"2020-03-28T12:08:05","date_gmt":"2020-03-28T04:08:05","guid":{"rendered":"https:\/\/www.wjxy.net.cn\/?p=917"},"modified":"2023-10-10T10:02:01","modified_gmt":"2023-10-10T02:02:01","slug":"pve-%e8%a7%a3%e5%86%b3-etc-rc-local-%e5%bc%80%e6%9c%ba%e5%90%af%e5%8a%a8%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/www.wjxy.net.cn\/?p=917","title":{"rendered":"PVE \u89e3\u51b3 \/etc\/rc.local \u5f00\u673a\u542f\u52a8\u95ee\u9898"},"content":{"rendered":"\r\n<p>\u7531\u4e8e\u67d0\u4e9b\u8f6f\u4ef6\u5e76\u6ca1\u6709\u589e\u52a0\u5f00\u542f\u542f\u52a8\u7684\u670d\u52a1\uff0c\u5f88\u591a\u65f6\u5019\u9700\u8981\u624b\u5de5\u6dfb\u52a0\uff0c\u4e00\u822c\u6211\u4eec\u90fd\u662f\u63a8\u8350\u6dfb\u52a0\u547d\u4ee4\u5230\u00a0<code>\/etc\/rc.local<\/code>\u00a0\u6587\u4ef6\uff0c\u4f46\u662f Debian 9 \u9ed8\u8ba4\u4e0d\u5e26\u00a0<code>\/etc\/rc.local<\/code>\u00a0\u6587\u4ef6\uff0c\u800c\u00a0<code>rc.local<\/code>\u00a0\u670d\u52a1\u5374\u8fd8\u662f\u81ea\u5e26\u7684<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>cat \/lib\/systemd\/system\/rc.local.service\r\n#  SPDX-License-Identifier: LGPL-2.1+\r\n#\r\n#  This file is part of systemd.\r\n#\r\n#  systemd is free software; you can redistribute it and\/or modify it\r\n#  under the terms of the GNU Lesser General Public License as published by\r\n#  the Free Software Foundation; either version 2.1 of the License, or\r\n#  (at your option) any later version.\r\n\r\n# This unit gets pulled automatically into multi-user.target by\r\n# systemd-rc-local-generator if \/etc\/rc.local is executable.\r\n[Unit]\r\nDescription=\/etc\/rc.local Compatibility\r\nDocumentation=man:systemd-rc-local-generator(8)\r\nConditionFileIsExecutable=\/etc\/rc.local\r\nAfter=network.target\r\n\r\n[Service]\r\nType=forking\r\nExecStart=\/etc\/rc.local start\r\nTimeoutSec=0\r\nRemainAfterExit=yes\r\nGuessMainPID=no<\/code><\/pre>\r\n<p><span style=\"color: #ff0000;\">[Install] <\/span><\/p>\r\n<p><span style=\"color: #ff0000;\">WantedBy=multi-user.target<\/span><\/p>\r\n<p>&nbsp;<\/p>\r\n\r\n\r\n\r\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u8fd9\u4e2a\u670d\u52a1\u8fd8\u662f\u5173\u95ed\u7684\u72b6\u6001<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>systemctl status rc-local\r\n\u25cf rc-local.service - \/etc\/rc.local Compatibility\r\n   Loaded: loaded (\/lib\/systemd\/system\/rc-local.service; static; vendor preset: enabled)\r\n  Drop-In: \/lib\/systemd\/system\/rc-local.service.d\r\n           \u2514\u2500debian.conf\r\n   Active: inactive (dead)<\/code><\/pre>\r\n\r\n\r\n\r\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u624b\u5de5\u6dfb\u52a0\u4e00\u4e2a\u00a0<code>\/etc\/rc.local<\/code>\u00a0\u6587\u4ef6<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>cat &lt;&lt;EOF &gt;\/etc\/rc.local\r\n#!\/bin\/sh -e\r\n#\r\n# rc.local\r\n#\r\n# This script is executed at the end of each multiuser runlevel.\r\n# Make sure that the script will \"exit 0\" on success or any other\r\n# value on error.\r\n#\r\n# In order to enable or disable this script just change the execution\r\n# bits.\r\n#\r\n# By default this script does nothing.\r\n\r\nexit 0\r\nEOF\r\n\u7136\u540e\u8d4b\u4e88\u6743\u9650\r\nchmod +x \/etc\/rc.local<\/code><\/pre>\r\n\r\n\r\n\r\n<p>\u63a5\u7740\u542f\u52a8\u00a0<code>rc-local<\/code>\u00a0\u670d\u52a1<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>systemctl start rc-local<\/code><\/pre>\r\n\r\n\r\n\r\n<p>\u518d\u6b21\u67e5\u770b\u72b6\u6001<\/p>\r\n\r\n\r\n\r\n<pre class=\"wp-block-code\"><code>root@local:\/etc# systemctl status rc-local\r\n\u25cf rc-local.service - \/etc\/rc.local Compatibility\r\n   Loaded: loaded (\/lib\/systemd\/system\/rc-local.service; enabled-runtime; vendor preset: enabled)\r\n  Drop-In: \/usr\/lib\/systemd\/system\/rc-local.service.d\r\n           \u2514\u2500debian.conf\r\n   Active: active (exited) since Sat 2020-03-28 12:00:50 CST; 3min 46s ago\r\n     Docs: man:systemd-rc-local-generator(8)\r\n  Process: 734 ExecStart=\/etc\/rc.local start (code=exited, status=0\/SUCCESS)\r\n\r\nMar 28 12:00:50 yc systemd[1]: Starting \/etc\/rc.local Compatibility...\r\nMar 28 12:00:50 yc systemd[1]: Started \/etc\/rc.local Compatibility.<\/code><\/pre>\r\n\r\n\r\n\r\n<p>\u7136\u540e\u4f60\u5c31\u53ef\u4ee5\u628a\u9700\u8981\u5f00\u673a\u542f\u52a8\u7684\u547d\u4ee4\u6dfb\u52a0\u5230\u00a0<code>\/etc\/rc.local<\/code>\u00a0\u6587\u4ef6\uff0c\u4e22\u5728\u00a0<code>exit 0<\/code>\u00a0\u524d\u9762\u5373\u53ef\uff0c\u5e76\u5c1d\u8bd5\u91cd\u542f\u4ee5\u540e\u8bd5\u8bd5\u662f\u5426\u751f\u6548\u4e86<\/p>\r\n","protected":false},"excerpt":{"rendered":"<p>\u7531\u4e8e\u67d0\u4e9b\u8f6f\u4ef6\u5e76\u6ca1\u6709\u589e\u52a0\u5f00\u542f\u542f\u52a8\u7684\u670d\u52a1\uff0c\u5f88\u591a\u65f6\u5019\u9700\u8981\u624b\u5de5\u6dfb\u52a0\uff0c\u4e00\u822c\u6211\u4eec\u90fd\u662f\u63a8\u8350\u6dfb\u52a0\u547d\u4ee4\u5230\u00a0\/etc\/rc.loc [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/917"}],"collection":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=917"}],"version-history":[{"count":3,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/917\/revisions"}],"predecessor-version":[{"id":2968,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=\/wp\/v2\/posts\/917\/revisions\/2968"}],"wp:attachment":[{"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=917"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=917"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wjxy.net.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=917"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}