Ubuntu自動啟動配置指令碼
阿新 • • 發佈:2020-12-16
技術標籤:工具
Ubuntu自動啟動配置指令碼
使用下面的指令碼儲存檔案sudo執行一下即可;
手動一步一步操作比較累;
#!/bin/sh -e
cat > /lib/systemd/system/rc.local.service <<EOF
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
StandardOutput=tty
RemainAfterExit=no
GuessMainPID=no
[Install]
WantedBy=multi-user.target
Alias=rc-local.service
EOF
cat > /etc/rc.local <<EOF
#!/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.
EOF
chmod +x /etc/rc.local
ln -s /lib/systemd/system/rc.local.service /etc/systemd/system/rc.local.service
systemctl enable rc-local
systemctl status rc-local
參考自: https://blog.csdn.net/idiot_qi/article/details/86527052