RHCE7学习笔记6——控制服务和后台进程

1、控制服务(services and daemons)

    RHEL7以前的版本控制服务使用service XX start|stop|status:

[root@clz ~]# service sshd status

    RHEL7控制服务使用systemctl start|stop|status|restart  XX服务,查看服务的当前运行状态使用is-active:

[root@clz ~]# systemctl status sshd
[root@clz ~]# systemctl is-active sshd
active
[root@clz ~]# systemctl sart|stop|restart sshd

    查看某项服务是否会开机自动启动使用is-enable,相对应的是disable:

[root@clz ~]# systemctl is-enabled sshd
enabled

    禁用某项服务使用mask,相对应的是unmask:

    下面总结一下systemctl命令常用控制服务的选项:

  start [NAME...]                 Start (activate) one or more units 启动服务
  stop [NAME...]                  Stop (deactivate) one or more units 停止服务
  reload [NAME...]                Reload one or more units 重新加载
  restart [NAME...]               Start or restart one or more units 重新启动

  kill [NAME...]                  Send signal to processes of a unit 杀死进程
  is-active [NAME...]             Check whether units are active 是否启动
  is-failed [NAME...]             Check whether units are failed 是否失败
  status [NAME...|PID...]         Show runtime status of one or more units 状态
  enable [NAME...]                Enable one or more unit files 开机启动
  disable [NAME...]               Disable one or more unit files 开机不启动
  reenable [NAME...]              Reenable one or more unit files 重新设置开机启动
is-enabled [NAME...]            Check whether unit files are enabled 是否开机启动
  mask [NAME...]                  Mask one or more units 禁用服务
  unmask [NAME...]                Unmask one or more units 不禁用服务


    查看系统所有服务:systemctl list-units-all或system ctl list-units-files:

 [root@clz ~]# systemctl list-units
[root@clz ~]# systemctl list-unit-files

    加上type选项可以查看所有服务:

[root@clz ~]# systemctl list-unit-files --type service
UNIT FILE                                   STATE   
abrt-ccpp.service                           enabled 
abrt-oops.service                           enabled 
abrt-pstoreoops.service                     disabled


本文出自 “平凡之路” 博客,请务必保留此出处http://linjohn.blog.51cto.com/1026193/1599225

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。