Systemd usage

From wikinotes

Documentation

man systemctl https://man.archlinux.org/man/core/systemd/systemctl.1.en

Start/Stop

systemctl {list-units,list-timers,list-sockets}

systemctl {enable,start,stop,restart} myservice

systemctl {is-active,is-enabled} myservice

Management

systemctl --system daemon-reload          # reload unitfiles
systemctl [--user] list-units -t target   # list all targets

Logs

journalctl \
  # target
  /usr/bin/program    # for specific executable
  -u foo.service      # for specific service
  -b                  # boot messages

  # functions
  -f                  # tail logs

  # filters
  -p 7                # set loglevel 0-7 (priority)
  -g '.*foo$'         # grep logs
  -S,-U '2012-12-30'  # since/until (optional time '2012-12-30 18:00:00')