systemctl  -- 系统服务管理器

systemctl 是系统服务管理器命令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

直接运行命令可以列出所有正在运行的服务,输出列表具有更详细的信息,比如:

[root@beyes   command]# systemctl
... ...
sendmail.service          loaded active exited        LSB: start and stop sendmail
sshd.service              loaded active running       LSB: Start up the OpenSSH server daemon
udev.service              loaded active running       udev Kernel Device Manager
... ...

这里,还有一个 systemd-cgls 命令可以以树状的形式列出正在运行的进程信息。

如果要启动 httpd 服务,那么运行下面命令:

[root@beyes   command]# systemctl start httpd.service

注意,上面的 httpd 后面的 .service 是不能少的。

同理,停止服务和重启服务可以分别如下运行命令:

# systemctl stop httpd.service       #停止服务
# systemctl restart httpd.service              #重启服务

如果我们要查看服务的运行状态,那么如下运行:

[root@beyes   command]# systemctl status httpd.service
httpd.service - LSB: start and stop Apache HTTP Server
      Loaded: loaded (/etc/rc.d/init.d/httpd)
      Active: active (running) since Wed, 22 Feb 2012 10:37:30 +0800; 2s ago
     Process: 2573 ExecStop=/etc/rc.d/init.d/httpd stop (code=exited, status=0/SUCCESS)
     Process: 2589 ExecStart=/etc/rc.d/init.d/httpd start (code=exited, status=0/SUCCESS)
    Main PID: 2594 (httpd)
      CGroup: name=systemd:/system/httpd.service
          ├ 2594 /usr/sbin/httpd
          ├ 2596 /usr/sbin/httpd
          ├ 2597 /usr/sbin/httpd
          ├ 2598 /usr/sbin/httpd
          ├ 2599 /usr/sbin/httpd
          ├ 2600 /usr/sbin/httpd
          ├ 2601 /usr/sbin/httpd
          ├ 2602 /usr/sbin/httpd
          └ 2603 /usr/sbin/httpd

如果我们打算让服务可以随机启动,那么如下运行:

[root@beyes   command]# systemctl enable httpd.service
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd on

用 chkconfig 命令检测一下服务是否运行成功

[root@beyes   command]# chkconfig --list |grep httpd

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

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

可见服务已经在 第2 到 第5 运行等级打开。

同理禁止服务随机启动可以如下运行:

[root@beyes   command]# systemctl disable httpd.service
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd off

用 chkconfig 检测一下:

[root@beyes   command]# chkconfig --list |grep httpd

Note: This output shows SysV services only and does not include native
      systemd services. SysV configuration data might be overridden by native
      systemd configuration.

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

已经关闭成功。

此外,我们还可以直接检测服务是否随机启动或否,如下运行命令:

[root@beyes   command]# systemctl is-enabled httpd.service; echo $?
httpd.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig httpd --level=5
0

上面,0 表示该服务已经使能随机启动;如果返回 1 那么表示该服务不随机启动

ref:http://www.groad.net/bbs/simple/?t6224.html

systemctl -- 系统服务管理器 【转】的更多相关文章

  1. Atitit.木马病毒的操作注册表原理 系统服务管理器 atiSysService

    Atitit.木马病毒的操作注册表原理 系统服务管理器 atiSysService 1. atiSysService1 2. atiSysService  原理1 3. Java code1 4. 参 ...

  2. Atitit.跨语言系统服务管理器api兼容设计

    Atitit.跨语言系统服务管理器api兼容设计 1. Common api,兼容sc ,service control??1 1.1. 服务创建,use sc1 1.2. 服务delete ,use ...

  3. systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

    1.centos 检查服务是否开机自启  (ntpd是原生的服务,mysql是注册的服务) 参考:1.http://man.linuxde.net/systemctl

  4. Linux - 利用systemctl命令管理服务

    systemctl命令是系统服务管理器指令,融合了service和chkconfig的功能,可以查看和设置服务. 这里以docker服务为例. 利用systemctl命令管理 显示服务状态:syste ...

  5. Android提供的系统服务之--TelephonyManager(电话管理器)

    Android提供的系统服务之--TelephonyManager(电话管理器) 转载请注明出处--coder-pig TelephonyManager的作用: 用于管理手机通话状态,获取电话信息(设 ...

  6. CentOS7系统服务管理systemctl

    目录 一.systemctl介绍 二.systemctl常用命令 1.启动服务 2.停止服务 3.重启服务 4.查看服务是否已启动 5.查看服务的状态 6.启用开机自启动服务 7.停用开机自启动服务 ...

  7. centos7系统服务管理

    systemd是RH7系列操作系统开始启用新的系统和服务管理器.它被设计为与sysv init脚本向后兼容,并提供了一些功能,例如在引导时并行启动系统服务,按需激活守护程序或基于依赖关系的服务控制逻辑 ...

  8. “连接配置中心失败,将无法进行正常管理”--腾讯通RTX管理器

    [故障现象]: 腾讯通RTX管理器提示“连接配置中心失败,将无法进行正常管理” [解决办法]: 在系统服务中启动“RTX_ConfigCenter”服务即可. 文章收集自网络

  9. Windows Server 2012 R2 服务器管理器介绍和配置使用

    1. 服务管理器是用于管理系统服务的管理工具.一般常用于windows系统,使用这个工具你可以启动.停止服务:设置服务是自动.手动启动或禁用:查看某个服务的相关信息:设置服务以什么用户启动等等(一般包 ...

随机推荐

  1. docker部署springboot项目

    本文介绍一下docker如何部署springboot项目. 前提条件: 1.可以运行jar包的环境 2.机器上已经安装了docker 3.准备部署的springboot的jar包 4.Dockerfi ...

  2. Standford CoreNLP使用

    1.官网https://stanfordnlp.github.io/CoreNLP/ 2. 待续...

  3. [转]REMOTE_ADDR,HTTP_CLIENT_IP,HTTP_X_FORWARDED_FOR

    午睡一觉醒来,突然想伪造IP地址.搜了一下,Mark. 源地址:http://www.cnblogs.com/lmule/archive/2010/10/15/1852020.html ------- ...

  4. Wannafly Winter Camp 2019.Day 8 div1 I.岸边露伴的人生经验(FWT)

    题目链接 \(Description\) 给定\(n\)个十维向量\(\overrightarrow{V_i}=x_1,x_2,...,x_{10}\).定义\(\overrightarrow{V}= ...

  5. 【ACM】 1231 最大连续子序列

    [1231 最大连续子序列 ** Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...

  6. 烧写树莓派系统,SSH配置,无屏登录流程

    首先去 https://downloads.raspberrypi.org/raspbian/images/ 下载需要的版本镜像 我这里下载 https://downloads.raspberrypi ...

  7. iframe边距问题解决

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  8. 什么是redis?redis有什么用途?

    1. Redis: 1.1. 什么是redis: redis是一个开源(BSD许可)的,内存中的数据结构存储系统 1.2. Redis的用途: 数据库.缓存和消息中间件 1.3. 数据类型: 字符串( ...

  9. 删除office拥有多个都需要激活的授权信息

    首先确认office目录下存在“ospp.vbs”文件,可以搜索确认文件路径. 我的是在C:\Program Files\Microsoft Office\Office16  然后以管理员身份打开cm ...

  10. Oracle CPU使用率过高问题处理

    1.下载Process Explorer 2.打开Process Explorer,查看CPU使用情况最高的进程 3.双击该进程,查看详情 \ 4.    获取cpu使用最好的线程tid 5.     ...