目录
Red Hat Enterprise Linux 7之前版本的Linux系统中,是通过位于/etc/rc.d/init.d/目录中的init脚本对服务进行管理,在Linux 7版本中,这些脚本被服务单元取代,并对服务进行管理,服务单元以.service为扩展名。
1 service与systemctl的比较
service |
systemctl |
描述 |
service name start |
systemctl start name.service |
启动服务; |
service name stop |
systemctl stop name.service |
停止服务; |
service name restart |
systemctl restart name.service |
重启服务; |
service name condrestart |
systemctl try-restart name.service |
服务运行时重启服务; |
service name reload |
systemctl reload name.service |
重新加载配置; |
service name status |
systemctl status name.service |
查看服务状态; |
systemctl is-active name.service |
||
service --status-all |
systemctl list-units --type service --all |
查看所有服务的状态; |
2 chkconfig与systemctl的比较
chkconfig |
systemctl |
描述 |
chkconfig name on |
systemctl enable name.service |
激活服务; |
chkconfig name off |
systemctl disable name.service |
禁用服务; |
chkconfig --list name |
systemctl status name.service |
检查服务是否激活; |
systemctl is-enable name.service |
||
chkconfig --list |
systemctl list-unit-files --type service |
列出所有服务,检查是否激活; |
chkconfig --list |
systemctl list-dependecies --after |
列出在指定单元之前按顺序启动的服务; |
chkconfig --list |
systemctl list-dependecies --before |
列出在指定单元之后按顺序启动的服务; |