centos7中启用rc-local服务

无所事事1年前日常记录469

简介

大多时候我们可以在/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/


相关文章

将bat文件或exe程序注册成windows服务

命令行使用sc命令.关于sc命令的详解,请自行查看帮助(sc /?),在此只简单提及如何加入系统服务功能.加入服务:sc create ServiceName binPath= 路径 start= a...

elasticsearch中使用curl进行的简单查询

curl:-X :指定http的请求方式,有HEAD、GET、POST、PUT、DELETE-d :指定要传输的数据-H :指定http的请求头信息curl -XPUT http://ip:port/...

使用 netboot.xyz 工具重装甲骨文 oracle cloud 实例系统

使用 netboot.xyz 工具重装甲骨文 oracle cloud 实例系统

文章出处:使用 netboot.xyz 工具重装甲骨文 oracle cloud 实例系统利用netboot.xyz工具,拯救甲骨文oracle cloud实例重装系统甲骨文默认是无法重装系统的,甲骨...

关于使用讯搜(xunsearch)过程中遇到的坑

1. 在xunsearch中按区间搜索的方法`$search->addRange('字段名','from','to')`- 第一个参数为字段名-...

XunSearch设置为服务 开机自动启动

开机自动启动[Uint] Description=xunsearch   [Service] Type=forking ExecStart=/bin/sh /usr/lo...

ElasticSearch搜索建议与上下文提示

ElasticSearch搜索建议与上下文提示

搜索建议通过Suggester Api实现原理是将输入的文本分解为Token,然后在词典中查找类似的Term返回根据不同场景,ElasticSearch设计了4中类别的Suggesters。Term...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。