Posted: . At: 8:59 AM. This was 5 years ago. Post ID: 12961
Page permalink. WordPress uses cookies, or tiny pieces of information stored on your computer, to verify who you are. There are cookies for logged in users and for commenters.
These cookies expire two weeks after they are set.


get information about running processes using Systemd.


The sudo systemctl status command will show a tree view of all running processes on your Linux machine. This is quite comprehensive and very useful output.

Here is a sample.

4.4 Mon Mar 04 jason@Yog-Sothoth 1: $ sudo systemctl status
● Yog-Sothoth
    State: running
     Jobs: 0 queued
   Failed: 0 units
    Since: Mon 2019-03-04 18:52:58 AEDT; 10h left
   CGroup: /
           ├─user.slice
           │ ├─user-123.slice
           │ │ ├─session-c4.scope
           │ │ │ ├─2467 gdm-session-worker [pam/gdm-launch-environment]
           │ │ │ ├─2520 /usr/lib/gdm3/gdm-x-session gnome-session --autostart /usr/share/gdm/greeter/autostart
           │ │ │ ├─2522 /usr/lib/xorg/Xorg vt1 -displayfd 3 -auth /run/user/123/gdm/Xauthority -background none -noreset -keeptty -verbose 3
           │ │ │ ├─2541 /usr/lib/gnome-session/gnome-session-binary --autostart /usr/share/gdm/greeter/autostart
           │ │ │ ├─2560 /usr/bin/gnome-shell
           │ │ │ ├─3120 ibus-daemon --xim --panel disable
           │ │ │ ├─3133 /usr/lib/ibus/ibus-dconf
           │ │ │ ├─3135 /usr/lib/ibus/ibus-x11 --kill-daemon
           │ │ │ ├─3407 /usr/lib/gnome-settings-daemon/gsd-xsettings
           │ │ │ ├─3410 /usr/lib/gnome-settings-daemon/gsd-a11y-settings
           │ │ │ ├─3411 /usr/lib/gnome-settings-daemon/gsd-clipboard
           │ │ │ ├─3419 /usr/lib/gnome-settings-daemon/gsd-color
           │ │ │ ├─3422 /usr/lib/gnome-settings-daemon/gsd-datetime
           │ │ │ ├─3427 /usr/lib/gnome-settings-daemon/gsd-housekeeping
           │ │ │ ├─3435 /usr/lib/gnome-settings-daemon/gsd-keyboard
           │ │ │ ├─3439 /usr/lib/gnome-settings-daemon/gsd-media-keys
           │ │ │ ├─3445 /usr/lib/gnome-settings-daemon/gsd-mouse
           │ │ │ ├─3446 /usr/lib/gnome-settings-daemon/gsd-power
           │ │ │ ├─3451 /usr/lib/gnome-settings-daemon/gsd-print-notifications
           │ │ │ ├─3457 /usr/lib/gnome-settings-daemon/gsd-rfkill
           │ │ │ ├─3462 /usr/lib/gnome-settings-daemon/gsd-screensaver-proxy
           │ │ │ ├─3465 /usr/lib/gnome-settings-daemon/gsd-sharing
           │ │ │ ├─3468 /usr/lib/gnome-settings-daemon/gsd-smartcard
           │ │ │ ├─3473 /usr/lib/gnome-settings-daemon/gsd-sound
           │ │ │ ├─3476 /usr/lib/gnome-settings-daemon/gsd-wacom
           │ │ │ └─3502 /usr/lib/ibus/ibus-engine-simple
           │ │ └─user@123.service
           │ │   ├─xdg-permission-store.service
           │ │   │ └─3364 /usr/lib/xdg-desktop-portal/xdg-permission-store
           │ │   ├─pulseaudio.service
           │ │   │ └─2593 /usr/bin/pulseaudio --daemonize=no
           │ │   ├─init.scope
           │ │   │ ├─2508 /lib/systemd/systemd --user
           │ │   │ └─2509 (sd-pam)
           │ │   ├─at-spi-dbus-bus.service
           │ │   │ ├─2543 /usr/lib/at-spi2-core/at-spi-bus-launcher
           │ │   │ ├─2548 /usr/bin/dbus-daemon --config-file=/usr/share/defaults/at-spi2/accessibility.conf --nofork --print-address 3
           │ │   │ └─2551 /usr/lib/at-spi2-core/at-spi2-registryd --use-gnome-session
           │ │   └─dbus.service
           │ │     ├─2534 /usr/bin/dbus-daemon --session --address=systemd: --nofork --nopidfile --systemd-activation --syslog-only
           │ │     └─3139 /usr/lib/ibus/ibus-portal
           │ └─user-1000.slice
           │   ├─user@1000.service
           │   │ ├─gvfs-goa-volume-monitor.service

To get information about just one process, use this command.

4.4 Mon Mar 04 jason@Yog-Sothoth 1: $ sudo systemctl status mysql.service
● mysql.service - MySQL Community Server
   Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2019-03-04 07:51:59 AEDT; 58min ago
  Process: 1763 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
  Process: 1671 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 1765 (mysqld)
    Tasks: 28 (limit: 4915)
   CGroup: /system.slice/mysql.service
           └─1765 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid
 
Mar 04 07:53:50 Yog-Sothoth systemd[1]: Starting MySQL Community Server...
Mar 04 07:51:59 Yog-Sothoth systemd[1]: Started MySQL Community Server.

This can also show messages pertaining to the service, as well as all instances that are running and their PID.

4.4 Mon Mar 04 jason@Yog-Sothoth 1: $ sudo systemctl status apache2.service
● apache2.service - The Apache HTTP Server
   Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
  Drop-In: /lib/systemd/system/apache2.service.d
           └─apache2-systemd.conf
   Active: active (running) since Mon 2019-03-04 07:53:55 AEDT; 57min ago
  Process: 6790 ExecReload=/usr/sbin/apachectl graceful (code=exited, status=0/SUCCESS)
  Process: 1672 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
 Main PID: 1749 (apache2)
    Tasks: 6 (limit: 4915)
   CGroup: /system.slice/apache2.service
           ├─1749 /usr/sbin/apache2 -k start
           ├─6794 /usr/sbin/apache2 -k start
           ├─6795 /usr/sbin/apache2 -k start
           ├─6796 /usr/sbin/apache2 -k start
           ├─6797 /usr/sbin/apache2 -k start
           └─6798 /usr/sbin/apache2 -k start
 
Mar 04 07:53:50 Yog-Sothoth systemd[1]: Starting The Apache HTTP Server...
Mar 04 07:53:54 Yog-Sothoth apachectl[1672]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppre
Mar 04 07:53:55 Yog-Sothoth systemd[1]: Started The Apache HTTP Server.
Mar 04 07:56:44 Yog-Sothoth systemd[1]: Reloading The Apache HTTP Server.
Mar 04 07:56:44 Yog-Sothoth apachectl[6790]: AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppre
Mar 04 07:56:44 Yog-Sothoth systemd[1]: Reloaded The Apache HTTP Server.

Another good reason to run Systemd on your Linux machine. This makes retrieving information about a running service even easier than before.

Use this command to show the properties of a running service.

4.4 Mon Mar 04 jason@Yog-Sothoth 1: $ sudo systemctl show mysql.service

This is a part of the output, this shows everything you could possibly want.

Type=forking
Restart=on-failure
PIDFile=/run/mysqld/mysqld.pid
NotifyAccess=none
RestartUSec=100ms
TimeoutStartUSec=10min
TimeoutStopUSec=10min
RuntimeMaxUSec=infinity
WatchdogUSec=0
WatchdogTimestamp=Mon 2019-03-04 07:51:59 AEDT
WatchdogTimestampMonotonic=110219190
PermissionsStartOnly=yes
RootDirectoryStartOnly=no
RemainAfterExit=no
GuessMainPID=yes
MainPID=1765
ControlPID=0
FileDescriptorStoreMax=0
NFileDescriptorStore=0
StatusErrno=0
Result=success

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.