手机版
你好,游客 登录 注册 搜索
背景:
阅读新闻

Linux基础教程学习笔记8——控制服务和后台进程

[日期:2015-03-09] 来源:Linux社区  作者:linjohn [字体: ]

Linux基础教程学习笔记8——控制服务和后台进程

1、控制服务(services and daemons)

RHEL7以前的版本控制服务使用service XX start|stop|status:
[root@linuxidc ~]# service sshd status

RHEL7控制服务使用systemctl start|stop|status|restart  XX服务,查看服务的当前运行状态使用is-active:
[root@linuxidc ~]# systemctl status sshd

[root@linuxidc ~]# systemctl is-active sshd
active

[root@linuxidc ~]# systemctl sart|stop|restart sshd

查看某项服务是否会开机自动启动使用is-enable,相对应的是disable:
[root@linuxidc ~]# 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@linuxidc ~]# systemctl list-units

[root@linuxidc ~]# systemctl list-unit-files

加上type选项可以查看所有服务:
[root@linuxidc ~]# systemctl list-unit-files --type service
UNIT FILE                                  STATE   
abrt-ccpp.service                          enabled 
abrt-oops.service                          enabled 
abrt-pstoreoops.service                    disabled

本文永久更新链接地址http://www.linuxidc.com/Linux/2015-03/114712.htm

linux
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款