设置开机自启一般都在rc.local
文件里设置,但是有的Ubuntu版本没有这个文件,此时可以自己创建一个。
创建rc.service文件
vi /etc/systemd/system/rc.service
粘贴以下内容到文件里
[Unit]
Description=/etc/rc.local Compatibility
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
启动rc.service服务并设置开机自启
systemctl start rc.service
systemctl enable rc.service
/etc/rc.local文件
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
评论