Systemd usage: Difference between revisions

From wikinotes
Line 22: Line 22:
<blockquote>
<blockquote>
<syntaxhighlight lang="bash">
<syntaxhighlight lang="bash">
sudo systemctl --system daemon-reload   # reload unitfiles
systemctl --system daemon-reload         # reload unitfiles
systemctl [--user] list-units -t target  # list all targets
</syntaxhighlight>
</syntaxhighlight>
</blockquote><!-- Management -->
</blockquote><!-- Management -->

Revision as of 16:40, 23 April 2022

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')