c.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