centos7中启用rc-local服务

简介

大多时候我们可以在/etc/rc.local中写一些命令来启动自己的程序或服务,但是配置后无法启动,查看了下是rc-local.service未启动

[root@master ~]# systemctl enable rc-local.service
[root@master ~]# systemctl start rc-local.service
[root@master ~]# systemctl status rc-local.service 
● rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
   Active: inactive (dead)
Condition: start condition failed at Tue 2019-05-21 20:22:46 CST; 1s ago
           ConditionFileIsExecutable=/etc/rc.d/rc.local was not met

默认情况下,使用上面的命令无法启动rc-local.service服务,原因是需要两处文件都设置可执行权限,但是 /etc/rc.d/rc.local 默认没有可执行权限

解决方法

## 设置可执行权限
[root@master ~]# chmod +x /etc/rc.d/rc.local
[root@master ~]# chmod +x /etc/rc.local

启动并查看状态

[root@master ~]# systemctl start rc-local.service 
[root@master ~]# systemctl status rc-local.service 
● rc-local.service - /etc/rc.d/rc.local Compatibility
   Loaded: loaded (/usr/lib/systemd/system/rc-local.service; static; vendor preset: disabled)
   Active: active (exited) since Tue 2019-05-21 20:23:54 CST; 1s ago
  Process: 5141 ExecStart=/etc/rc.d/rc.local start (code=exited, status=0/SUCCESS)

May 21 20:23:54 master systemd[1]: Starting /etc/rc.d/rc.local Compatibility...
May 21 20:23:54 master systemd[1]: Started /etc/rc.d/rc.local Compatibility.

引用

https://www.cipheronic.com/rc-local-service-enabling-on-centos7/

评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值