【Linux】在 Debian 9 (Stretch) 中啟用消失的 rc.local
強大的信心,能克服來自內心的惡魔,產生無往不勝的勇氣。
寧願辛苦一陣子,不要辛苦一輩子。
遠大的目的非常重要,一定要有成功的企圖心,而且越大越好。
人生最大的敵人是自己怯懦。
每天只看目的,別老想障礙。
Debian 9 (Stretch)預設不使用 rc.local, 所以會找不到/etc/rc.local 檔.
但是還是有辦法可以使用rc.local
首先自己先創造/etc/rc.local檔 :
————————————————
# cat <<EOF >/etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
EOF
————————————————
設定可執行權限:
# chmod +x /etc/rc.local
然後啟用rc-local 這個服務即可
# systemctl start rc-local
————————————————
觀察rc-local 這個服務是否已經啟動:
# systemctl status rc-local
● rc-local.service – /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: active (exited) since Wed 2017-08-16 14:12:44 CST; 5s ago
Process: 1256 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
Aug 16 14:12:44 vmsrv systemd[1]: Starting /etc/rc.local Compatibility…
Aug 16 14:12:44 vmsrv systemd[1]: Started /etc/rc.local Compatibility.
————————————————
參考資料: Where is rc.local in Debian 9 (Debian Stretch)
https://stackoverflow.com/questions/44797694/where-is-rc-local-in-debian-9-debian-stretch