ubuntu没有/etc/rc.local解决办法,设置开机自启动

解决方法:

首先创建systemd的服务脚本

1、sudo vi /etc/systemd/system/rc-local.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
#sysVstart这行可以删掉,我看启动日志中貌似报忽略这个了。。
 
[Install]
 WantedBy=multi-user.target

2、sudo systemctl enable rc-local.service

然后就按以前的格式编辑/etc/rc.local就好了。

最后记得chmod +x /etc/rc.local

发布了1230 篇原创文章 · 获赞 310 · 访问量 223万+

猜你喜欢

转载自blog.csdn.net/huangbaokang/article/details/105413009
今日推荐