Systemd: Difference between revisions

From Edgar BV Wiki
Jump to navigation Jump to search
No edit summary
Line 17: Line 17:
<pre>
<pre>
[Unit]
[Unit]
After=grafana.service
Description=Evologger instance
Documentation=https://wiki.edgarbv.com/index.php?title=My_guide_to_grafana_/_influxdb
Wants=network-online.target
After=network-online.target
After=grafana.service grafana-server.service  mariadb.service mysql.service


[Service]
[Service]
ExecStart=/opt/evologger/evologger.py & > /var/log/evologger
User=evologger
Group=evologger
Restart=on-failure
ExecStart=/opt/evologger/evologger.sh &>>/var/log/evologger


[Install]
[Install]

Revision as of 13:06, 26 June 2019

services

You can use the service or systemctl commands to work with these. Apparently systemctl is more direct and service is a wrapper script.

   systemctl start|stop|restart|status service

To find out if a service is enabled / will start up at boot

   systemctl is-enabled service

To enable|disable it at boot

   systemctl enable|disable service

To get a script to start as a service

  vi /usr/lib/systemd/system/SCRIPTNMAME.service
[Unit]
Description=Evologger instance
Documentation=https://wiki.edgarbv.com/index.php?title=My_guide_to_grafana_/_influxdb
Wants=network-online.target
After=network-online.target
After=grafana.service grafana-server.service  mariadb.service mysql.service

[Service]
User=evologger
Group=evologger
Restart=on-failure
ExecStart=/opt/evologger/evologger.sh &>>/var/log/evologger

[Install]
WantedBy=default.target

After editing these scripts always do

  systemctl daemon-reload

logs

How To Use Journalctl to View and Manipulate Systemd Logs

To filter by unit (a unit can be all kinds of stuff)

   journalctl -u service|username|groupname

show all information (instead of truncated)

   journalctl -a

to throw the output to stdout instead of the less pager

   journalctl --no-pager

to follow output live

   journalctl -f