SysV服务chkconfig命令service命令和systemd服务管理systemctl命令
1.说明
在CentOS6.X中SysV服务用命令chkconfig/service来管理服务,而在CentOS7.X将由systemd的systemctl命令来管理服务。以下是SysV与systemd服务控制表
2.服务控制表
| SysV服务 | systemd服务 | 作用 |
|---|---|---|
| service NAME stop | systemctl stop NAME | 停止服务 |
| service NAME status | systemctl status NAME | 看服务运行状态 |
| service NAME start | systemctl start NAME | 启动服务 |
| service NAME restart | systemctl restart NAME | 重启服务 |
| service NAME reload | systemctl reload NAME | 重新加载配置(不终止服务) |
| chkconfig NAME on | systemctl enable NAME | 开机自动启动 |
| chkconfig NAME off | systemctl disable NAME | 开机不自动启动 |
| chkconfig --list NAME | systemctl is-enabled NAME | 查看指定服务是否为开机自启动 |
| chkconfig --list | systemctl list-unit-files | 查看服务的启动和禁用状态 |
| chkconfig --add NAME | systemctl daemon-reload | 创建新服务文件或变量设置 |
| systemctl is-active NAME | 查看服务是否在运行中 | |
| systemctl mask NAME | 禁止服务运行 | |
| systemctl unmask NAME | 取消禁止服务运行 |
3.服务状态说明
| 服务状态 | 状态说明 |
|---|---|
| loaded | 服务单元配置文件已被处理 |
| active(running) | 服务的一个或多个进程在运行中 |
| active(exited) | 一次性运行的服务成功被执行并退出(服务运行任务后,相关进程会自动退出) |
| active(waiting) | 服务已经运行但在等待某个事件 |
| inactive | 服务没有在运行 |
| enabled | 服务设置为开机启动 |
| disabled | 服务设置为开机不启动 |
| static | 服务不能被设置开机启动,但可以由其它服务启动该服务 |
4.更多参考
Wiki:点击到达
本文介绍了在CentOS系统中,从老版本的SysV服务到新版本systemd服务的管理命令转换。在CentOS6.X中使用chkconfig和服务命令管理服务,而在CentOS7.X及更高版本则使用systemctl命令。文章通过服务控制表详细列举了两个系统下启动、停止、检查服务状态以及配置开机启动等操作的对应命令。同时,解释了服务的不同状态,如loaded、active(running)等,并提供了更多参考资料链接。
1525

被折叠的 条评论
为什么被折叠?



