返回列表 发帖

[软件故障] CentOS设置随机启动无效的解决方法

问题:俄罗斯VPS,CentOS 7 x64
/etc/rc.d/rc.local中添加启动项并
chmod +x /etc/rc.d/rc.local
但无法随机启动

检测随机启动项是否正常:
[root@vm6666 ~]# systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Thu 2019-05-16 23:40:11 CST; 7min ago
  Process: 1633 ExecStart=/etc/rc.local start (code=exited, status=127)

May 16 23:40:10 vm6666.vds.lk3.ru systemd[1]: Starting /etc/rc.local Compatibility...
May 16 23:40:11 vm6666.vds.lk3.ru systemd[1]: rc-local.service: control process exited, code=exited status=127
May 16 23:40:11 vm6666.vds.lk3.ru systemd[1]: Failed to start /etc/rc.local Compatibility.
May 16 23:40:11 vm6666.vds.lk3.ru systemd[1]: Unit rc-local.service entered failed state.
May 16 23:40:11 vm6666.vds.lk3.ru systemd[1]: rc-local.service failed.

检测服务是否正常:
systemctl | grep "rc.local"
[root@vm6666 etc]# systemctl | grep "rc.local"
● rc-local.service                                                 loaded failed failed    /etc/rc.local Compatibility

解决
/etc/rc.d/rc.local中首行添加
#!/bin/bash

保存,之后随机启动正常。

[root@vm6666 ~]# systemctl | grep "rc.local"
  rc-local.service                                                  loaded active running   /etc/rc.local Compatibility
[root@vm6666 ~]# systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
   Loaded: loaded (/etc/systemd/system/rc-local.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2019-05-17 00:02:10 CST; 36s ago
  Process: 1652 ExecStart=/etc/rc.local start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/rc-local.service
           ├─2669 /root/vpnserver/vpnserver execsvc
           ├─2671 /root/vpnserver/vpnserver execsvc
           ├─3423 /root/vpnclient/vpnclient execsvc
           ├─3426 /root/vpnclient/vpnclient execsvc
           └─3845 python server.py m

May 17 00:01:58 vm6666.vds.lk3.ru systemd[1]: Starting /etc/rc.local Compatibility...
May 17 00:02:10 vm6666.vds.lk3.ru systemd[1]: Started /etc/rc.local Compatibility.
欢迎光临:逐梦论坛

返回列表

Powered by Discuz! 7.2   论坛QQ群:逐梦论坛群

© 2001-2021 Comsenz Inc. 本站服务器由0634云主机提供 鲁公网安备 37120302000001号