本文最后更新于 545 天前,其中的信息可能已经有所发展或是发生改变。
发现自定义的启动命令无法生效,导致安装的一些服务无法自动启动,每次重启系统都要手动启动,很麻烦,鸽了好久,终于解决了。
首先打开rc.local
文件,备份内容,然后删除这个文件。使用xshell登录服务器,重新创建启动文件
cd /etc
nano /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
按下Ctrl+x
保存退出,然后输入y确定,最后回车保存。
赋予权限
chmod +x /etc/rc.local
添加到系统启动
systemctl enable rc-local
启动 rc-local 服务
systemctl start rc-local
检查启动状态
systemctl status rc-local.service
恢复正常。然后再添加自定义命令,添加到exit 0
之前。
发现是Docker的虚拟网络命令冲突了,删掉。
重启
systemctl restart rc-local
再次检查启动状态
systemctl status rc-local.service
没问题了。所以其实根本不需要重建rc.local文件o(╥﹏╥)o