3.7.6 Displaying the Status of Services

You can use the is-active subcommand to check whether a service is running (active) or not running (inactive):

# systemctl is-active httpd
active
# systemctl is-active nfs
inactive

You can use the status action to view a detailed summary of the status of a service, including a tree of all the tasks in the control group (cgroup) that the service implements:

# systemctl status httpd
httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled)
   Active: active (running) since Mon 2014-04-28 15:02:40 BST; 1s ago
 Main PID: 6452 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─6452 /usr/sbin/httpd -DFOREGROUND
           ├─6453 /usr/sbin/httpd -DFOREGROUND
           ├─6454 /usr/sbin/httpd -DFOREGROUND
           ├─6455 /usr/sbin/httpd -DFOREGROUND
           ├─6456 /usr/sbin/httpd -DFOREGROUND
           └─6457 /usr/sbin/httpd -DFOREGROUND

Apr 28 15:02:40 localhost.localdomain systemd[1]: Started The Apache HTTP Ser...
Hint: Some lines were ellipsized, use -l to show in full.

A cgroup is a collection of processes that are bound together so that you can control their access to system resources. In the example, the cgroup for the httpd service is httpd.service, which is in the system slice.

Slices divide the cgroups on a system into different categories. To display the slice and cgroup hierarchy, use the systemd-cgls command:

# systemd-cgls
├─user.slice
│ ├─user-1000.slice
│ │ └─session-12.scope
│ │   ├─3152 gdm-session-worker [pam/gdm-password]
│ │   ├─3169 /usr/bin/gnome-keyring-daemon --daemonize --login
│ │   ├─3171 gnome-session --session gnome-classic
│ │   │ ...
│ │   └─3763 /usr/libexec/evolution-calendar-factory
│ └─user-0.slice
│   ├─session-13.scope
│   │ ├─3810 sshd: root@pts/0    
│   │ ├─3836 -bash
│   │ ├─4015 systemd-cgls
│   │ └─4016 systemd-cgls
│   └─session-6.scope
│     └─3030 /usr/sbin/anacron -s
└─system.slice
  ├─1 /usr/lib/systemd/systemd --switched-root --system --deserialize 23
  ├─bluetooth.service
  │ └─3421 /usr/sbin/bluetoothd -n
  ├─udisks2.service
  │ └─3420 /usr/lib/udisks2/udisksd --no-debug
  ├─colord.service
  │ └─2812 /usr/libexec/colord
  ├─upower.service
  │ └─2760 /usr/libexec/upowerd
  ├─iscsid.service
  │ ├─1288 /usr/sbin/iscsid
  │ └─1289 /usr/sbin/iscsid
  │ ...
  ├─dbus.service
  │ └─427 /bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --sy
  ├─firewalld.service
  │ └─391 /usr/bin/python /usr/sbin/firewalld --nofork --nopid
  ├─iprdump.service
  │ └─524 /sbin/iprdump --daemon
  ├─iprinit.service
  │ └─466 /sbin/iprinit --daemon
  ├─iprupdate.service
  │ └─467 /sbin/iprupdate --daemon
  └─network.service
    └─736 /sbin/dhclient -H localhost -1 -q -lf /var/lib/dhclient/dhclient-f174a

system.slice contains services and other system processes. user.slice contains user processes, which run within transient cgroups called scopes. In the example, the processes for the user with ID 1000 are running in the scope session-12.scope under the slice /user.slice/user-1000.slice.

You can use the systemctl command to limit the CPU, I/O, memory, and other resources that are available to the processes in service and scope cgroups. See Section 3.7.7, “Controlling Access to System Resources”.

For more information, see the systemctl(1) and systemd-cgls(1) manual pages.