Ubuntu 设置开机自启

ubuntu16.04

vim /etc/rc.local

ubuntu18.04

1、vim /etc/rc.local

#!/bin/sh -e

exit 0
 

2、sudo chmod 755 /etc/rc.local

3、vim /etc/systemd/system/rc-local.service

[Unit]
Description=/etc/rc.local Compatibility
Documentation=man:systemd-rc-local-generator(8)
ConditionFileIsExecutable=/etc/rc.local
After=network.target

[Service]
Type=forking
ExeAtart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
GuessMainPID=no

[Install]
WantedBy=multi-user.target
elias=rc-local.service
 

4、sudo chmod 755 /etc/systemd/system/rc-local.service

5、sudo systemctl daemon-reload
 

6、sudo systemctl enable rc.local.service

你可能感兴趣的:(其他,ubuntu,linux,运维)