博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
systemctl添加开机启动 & chkconfig 使用
阅读量:7133 次
发布时间:2019-06-28

本文共 1795 字,大约阅读时间需要 5 分钟。

hot3.png

我们对service和chkconfig两个命令都不陌生,systemctl 是管制服务的主要工具, 它整合了chkconfig 与 service功能于一体。

systemctl is-enabled iptables.service

systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable *.service #开机运行服务
systemctl disable *.service #取消开机运行
systemctl start *.service #启动服务
systemctl stop *.service #停止服务
systemctl restart *.service #重启服务
systemctl reload *.service #重新加载服务配置文件
systemctl status *.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

注:*代表某个服务的名字,如http的服务名为httpd

例如在CentOS 7 上安装http

[root ~]# yum -y install httpd

启动服务(等同于service httpd start)
systemctl start httpd.service
停止服务(等同于service httpd stop)
systemctl stop httpd.service
重启服务(等同于service httpd restart)
systemctl restart httpd.service
查看服务是否运行(等同于service httpd status)
systemctl status httpd.service
开机自启动服务(等同于chkconfig httpd on)
systemctl enable httpd.service
开机时禁用服务(等同于chkconfig httpd on)
systemctl disable httpd.service
查看服务是否开机启动 (等同于chkconfig --list)

------------------------------------------------------

centOS chkconfig 使用

安装centOS 后 某些服务不是自动启动

chkconfig 可以检查和 设置服务自动启动

#chkconfig --list

输出 所有服务列表

如果列表中没有你要启动的服务

可以使用

#chkconfig --add 添加进去:

#chkconfig --add postfix

删除自然就是

#chkconfig --del 添加进去:

#chkconfig --del postfix

 

--list 后面可以加 服务名称 就只输出此服务的信息

例如

#chkconfig --list httpd

httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

上面的输出 0-6 都为off 时 表示 没有自动启动

0-6 分别表示的是

 等级0表示:表示关机

 等级1表示:单用户模式
 等级2表示:无网络连接的多用户命令行模式
 等级3表示:有网络连接的多用户命令行模式
 等级4表示:不可用
 等级5表示:带图形界面的多用户模式
 等级6表示:重新启动

 

#chkconfig httpd on

就可以把httpd服务 设置为自动启动了

再次查看

#chkconfig --list httpd

httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off

这个时候2~5都是on,设置成功。

相反的

#chkconfig httpd off 就是 关闭自动启动

最后 还有个 --level 应该是对 0-6 某些 等级进行单独设置

#chkconfig --level 35 httpd on 将3和5 设置成on

------------------------------------------------------

转载于:https://my.oschina.net/clin003/blog/2875711

你可能感兴趣的文章
用C做的电子时钟程序
查看>>
符号引用(typeglob,别名)与全局变量的修改
查看>>
利用泛型实现通用的list和array转换
查看>>
打油诗 自嘲
查看>>
计划开始写redis的源码分析笔记
查看>>
java 空字条串空判断 效率
查看>>
js倒计时跳转页面
查看>>
如何在工作中自学UI设计
查看>>
Qt之布局管理——停靠窗口
查看>>
写了一个远程桌面管理的Visual Studio扩展程序
查看>>
字节流、字符串、16进制字符串转换__Java(转)
查看>>
监视在input框中按下回车(enter) js实现
查看>>
php分享三十三:常量
查看>>
重构之路 柳暗花明
查看>>
安卓学习----使用okHttp(POST方式)---登录
查看>>
POJ 2996 Help Me with the Game
查看>>
web.xml元素介绍
查看>>
Shell升级,/bin/bash版本号4.1到4.3
查看>>
linux乱码
查看>>
由浅入深表达式树(完结篇)重磅打造 Linq To 博客园
查看>>