Debian9 添加rc.local开机启动
相信不少朋友已经发现,在升级到Debian9之后,那个熟悉的开机启动项rc.local已经不见了,在自定义一些开机启动项目时变得不是那么方便了。好在这个功能并不是被砍掉了,而是默认没有开启,把它重新开启即可。
看一下这个服务的状态,默认是没有开启的。
systemctl status rc-local
现在来开启它,首先创建一个rc.local文件,里面包含下记内容,注意这16行是同一个命令,一次性全部复制到命令终端执行。
cat <<EOF >/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
EOF
授予执行权限
chmod +x /etc/rc.local
启动 rc-local 服务
systemctl start rc-local
现在再看看服务状态,显示已经激活。
systemctl status rc-local
现在可以把需要开机启动的项目添加到rc.local的exit 0前面,然后重启试试吧。