本文的操作系统是:
VERSION=”18.04.6 LTS (Bionic Beaver)”
1、查看/etc/systemd/system/rc-local.service 中是否有【Install】段(用于设置启动的的一些参数)
[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutStartSec=0
TimeoutStopSec=30
RemainAfterExit=yes
GuessMainPID=no
[Install]
WantedBy=multi-user.target
2、设置具体的开机自动执行的脚本:
cat /etc/rc.local
#!/bin/bash
# xxxx可以添加开机后自启动的命令
exit 0
加权限配置自动启动
chmod +x /etc/rc.local
systemctl enable rc-local
systemctl start rc-local.service
检查
systemctl status rc-local.service
以上骚操作一般都会搞定