2021-05-12 14:32:11
如何在 Debian 9 中增加 rc.local
rc.local在老版本的debian系統中是有的,6版本以後,這個就沒有了,這裡記錄一下Debian 9設定開機啟動指令碼的方式:
新增檔案:
vi /etc/systemd/system/rc-local.service
編輯內容:
[Unit]
Description=/etc/rc.local
ConditionPathExists=/etc/rc.local
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=yes
SysVStartPriority=99
[Install]
WantedBy=multi-user.target
新增檔案:
vi /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
新增許可權:
chmod +x /etc/rc.local
設定到系統啟動:
systemctl enable rc-local
啟動指令碼:
systemctl start rc-local.service
檢查服務狀態:
systemctl status rc-local.service
上面你已經成功的建立了一個系統啟動指令碼,接下來你就可以在/etc/rc.loacl中的exit前增加任意你想啟動的指令碼了,比如:
cd /home/wjf/flypig
sh run.sh
本文永久更新連結地址:https://www.linuxidc.com/Linux/2018-04/151670.htm
相關文章