{"id":8,"date":"2026-01-07T08:01:21","date_gmt":"2026-01-07T08:01:21","guid":{"rendered":"https:\/\/ceshi.303333.xyz\/?p=8"},"modified":"2026-01-07T08:01:21","modified_gmt":"2026-01-07T08:01:21","slug":"debian-%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.yun.com.mp\/?p=8","title":{"rendered":"Debian \u89e3\u51b3 \/etc\/rc.local \u5f00\u673a\u542f\u52a8\u95ee\u9898"},"content":{"rendered":"\n<p>\u672c\u6587\u540c\u6837\u9002\u7528\u4e8e Debian 9 Strech \u4e4b\u540e\u7684\u7248\u672c\u3002<\/p>\n\n\n\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\u4f7f\u7528&nbsp;<code>systemd<\/code>&nbsp;\u5199\u4e2a\u7cfb\u7edf\u670d\u52a1\uff0c\u4f46\u662f\u5bf9\u4e8e\u4e00\u4e9b\u7b80\u5355\u7684\u811a\u672c\u6216\u8005\u61d2\u4eba\u6765\u8bf4\uff0c\u6dfb\u52a0\u547d\u4ee4\u5230&nbsp;<code>\/etc\/rc.local<\/code>&nbsp;\u6587\u4ef6\u66f4\u65b9\u4fbf\uff0c\u4f46\u662f\u81ea\u4ece Debian 9 \u5f00\u59cb\uff0cDebian \u9ed8\u8ba4\u4e0d\u5e26&nbsp;<code>\/etc\/rc.local<\/code>&nbsp;\u6587\u4ef6\uff0c\u800c&nbsp;<code>rc.local<\/code>&nbsp;\u670d\u52a1\u5374\u8fd8\u662f\u81ea\u5e26\u7684\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # cat \/lib\/systemd\/system\/rc-local.service\n#  SPDX-License-Identifier: LGPL-2.1-or-later\n#\n#  This file is part of systemd.\n#\n#  systemd is free software; you can redistribute it and\/or modify it\n#  under the terms of the GNU Lesser General Public License as published by\n#  the Free Software Foundation; either version 2.1 of the License, or\n#  (at your option) any later version.\n\n# This unit gets pulled automatically into multi-user.target by\n# systemd-rc-local-generator if \/etc\/rc.local is executable.\n&#91;Unit]\nDescription=\/etc\/rc.local Compatibility\nDocumentation=man:systemd-rc-local-generator(8)\nConditionFileIsExecutable=\/etc\/rc.local\nAfter=network.target\n\n&#91;Service]\nType=forking\nExecStart=\/etc\/rc.local start\nTimeoutSec=0\nRemainAfterExit=yes\nGuessMainPID=no\n<\/code><\/pre>\n\n\n\n<p>\u5e76\u4e14\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u8fd9\u4e2a\u670d\u52a1\u8fd8\u662f\u5173\u95ed\u7684\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # systemctl status rc-local\n\u25cf rc-local.service - \/etc\/rc.local Compatibility\n     Loaded: loaded (\/lib\/systemd\/system\/rc-local.service; static)\n    Drop-In: \/usr\/lib\/systemd\/system\/rc-local.service.d\n             \u2514\u2500debian.conf\n     Active: inactive (dead)\n       Docs: man:systemd-rc-local-generator(8)\n<\/code><\/pre>\n\n\n\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u624b\u5de5\u6dfb\u52a0\u4e00\u4e2a&nbsp;<code>\/etc\/rc.local<\/code>&nbsp;\u6587\u4ef6\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &lt;&lt;EOF &gt;\/etc\/rc.local\n#!\/bin\/sh -e\n#\n# rc.local\n#\n# This script is executed at the end of each multiuser runlevel.\n# Make sure that the script will \"exit 0\" on success or any other\n# value on error.\n#\n# In order to enable or disable this script just change the execution\n# bits.\n#\n# By default this script does nothing.\n\nexit 0\nEOF\n<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u8d4b\u4e88\u6743\u9650\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>chmod +x \/etc\/rc.local\n<\/code><\/pre>\n\n\n\n<p>\u63a5\u7740\u542f\u52a8&nbsp;<code>rc-local<\/code>&nbsp;\u670d\u52a1\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>systemctl enable --now rc-local\n<\/code><\/pre>\n\n\n\n<p>\u6b64\u65f6\u53ef\u80fd\u4f1a\u5f39\u51fa\u8b66\u544a\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>The unit files have no installation config (WantedBy=, RequiredBy=, Also=,\nAlias= settings in the &#91;Install] section, and DefaultInstance= for template\nunits). This means they are not meant to be enabled using systemctl.\n \nPossible reasons for having this kind of units are:\n\u2022 A unit may be statically enabled by being symlinked from another unit's\n  .wants\/ or .requires\/ directory.\n\u2022 A unit's purpose may be to act as a helper for some other unit which has\n  a requirement dependency on it.\n\u2022 A unit may be started when needed via activation (socket, path, timer,\n  D-Bus, udev, scripted systemctl call, ...).\n\u2022 In case of template units, the unit is meant to be enabled with some\n  instance name specified.\n<\/code><\/pre>\n\n\n\n<p>\u65e0\u89c6\u8b66\u544a\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u670d\u52a1\u6ca1\u6709\u4efb\u4f55\u4f9d\u8d56\u7684\u7cfb\u7edf\u670d\u52a1\uff0c\u53ea\u662f\u5f00\u673a\u542f\u52a8&nbsp;<code>\/etc\/rc.local<\/code>&nbsp;\u811a\u672c\u800c\u5df2\u3002<\/p>\n\n\n\n<p>\u518d\u6b21\u67e5\u770b\u72b6\u6001\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>root@debian ~ # systemctl status rc-local.service \n\u25cf rc-local.service - \/etc\/rc.local Compatibility\n     Loaded: loaded (\/lib\/systemd\/system\/rc-local.service; enabled-runtime; vendor preset: enabled)\n    Drop-In: \/usr\/lib\/systemd\/system\/rc-local.service.d\n             \u2514\u2500debian.conf\n     Active: active (exited) since Thu 2022-01-27 18:52:43 UTC; 10s ago\n       Docs: man:systemd-rc-local-generator(8)\n    Process: 541 ExecStart=\/etc\/rc.local start (code=exited, status=0\/SUCCESS)\n        CPU: 3ms\n\nJan 27 18:52:43 debian systemd&#91;1]: Starting \/etc\/rc.local Compatibility...\nJan 27 18:52:43 debian systemd&#91;1]: Started \/etc\/rc.local Compatibility.\n<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u4f60\u5c31\u53ef\u4ee5\u628a\u9700\u8981\u5f00\u673a\u542f\u52a8\u7684\u547d\u4ee4\u6dfb\u52a0\u5230&nbsp;<code>\/etc\/rc.local<\/code>&nbsp;\u6587\u4ef6\uff0c\u4e22\u5728&nbsp;<code>exit 0<\/code>&nbsp;\u524d\u9762\u5373\u53ef\uff0c\u5e76\u5c1d\u8bd5\u91cd\u542f\u4ee5\u540e\u8bd5\u8bd5\u662f\u5426\u751f\u6548\u4e86\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u540c\u6837\u9002\u7528\u4e8e Debian 9 Strech \u4e4b\u540e\u7684\u7248\u672c\u3002 \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\u4f7f\u7528&nbsp;systemd&nbsp;\u5199\u4e2a\u7cfb\u7edf\u670d\u52a1\uff0c\u4f46\u662f\u5bf9\u4e8e\u4e00\u4e9b\u7b80\u5355\u7684\u811a\u672c\u6216\u8005\u61d2\u4eba\u6765\u8bf4\uff0c\u6dfb\u52a0\u547d\u4ee4\u5230&nbsp;\/etc\/rc.local&nbsp;\u6587\u4ef6\u66f4\u65b9\u4fbf\uff0c\u4f46\u662f\u81ea\u4ece Debian 9 \u5f00\u59cb\uff0cDebian \u9ed8\u8ba4\u4e0d\u5e26&nbsp;\/etc\/rc.local&nbsp;\u6587\u4ef6\uff0c\u800c&nbsp;rc.local&nbsp;\u670d\u52a1\u5374\u8fd8\u662f\u81ea\u5e26\u7684\uff1a \u5e76\u4e14\u9ed8\u8ba4\u60c5\u51b5\u4e0b\u8fd9\u4e2a\u670d\u52a1\u8fd8\u662f\u5173\u95ed\u7684\u72b6\u6001\uff1a \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u6211\u4eec\u9700\u8981\u624b\u5de5\u6dfb\u52a0\u4e00\u4e2a&nbsp;\/etc\/rc.local&nbsp;\u6587\u4ef6\uff1a \u7136\u540e\u8d4b\u4e88\u6743\u9650\uff1a \u63a5\u7740\u542f\u52a8&nbsp;rc-local&nbsp;\u670d\u52a1\uff1a \u6b64\u65f6\u53ef\u80fd\u4f1a\u5f39\u51fa\u8b66\u544a\uff1a \u65e0\u89c6\u8b66\u544a\uff0c\u56e0\u4e3a\u8fd9\u4e2a\u670d\u52a1\u6ca1\u6709\u4efb\u4f55\u4f9d\u8d56\u7684\u7cfb\u7edf\u670d\u52a1\uff0c\u53ea\u662f\u5f00\u673a\u542f\u52a8&nbsp;\/etc\/rc.local&nbsp;\u811a\u672c\u800c\u5df2\u3002 \u518d\u6b21\u67e5\u770b\u72b6\u6001\uff1a \u7136\u540e\u4f60\u5c31\u53ef\u4ee5\u628a\u9700\u8981\u5f00\u673a\u542f\u52a8\u7684\u547d\u4ee4\u6dfb\u52a0\u5230&nbsp;\/etc\/rc.local&nbsp;\u6587\u4ef6\uff0c\u4e22\u5728&nbsp;exit 0&nbsp;\u524d\u9762\u5373\u53ef\uff0c\u5e76\u5c1d\u8bd5\u91cd\u542f\u4ee5\u540e\u8bd5\u8bd5\u662f\u5426\u751f\u6548\u4e86\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/8","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8"}],"version-history":[{"count":1,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions"}],"predecessor-version":[{"id":9,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=\/wp\/v2\/posts\/8\/revisions\/9"}],"wp:attachment":[{"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yun.com.mp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}