systemctl status myservice
systemctl is-active myservice
Will return 0 if the service is runningsystemctl is-enabled myservice
Will return 0 if the service will automatically start at boot timesystemctl is-failed myservice
Possible return options are: active, failed, unknown, inactiveTo view the logfile for the service...
journalctl -u myservice
To show the configuration file of a service...
systemctl cat myservice
To list all services...
systemctl list-units --type=service
systemctl start myservice
systemctl stop myservice
systemctl restart myservice
systemctl reload myservice
systemctl reload-or-restart myservice
Masking prevents a service being started (either manually or automatically)...
systemctl mask myservice
systemctl unmask myservice
touch /etc/systemd/system/myservice.service
chmod 644 /etc/systemd/system/myservice.service
For MySQL...
Example taken from MySQL documentation...[Unit]Description=MySQL ServerDocumentation=man:mysqld(8)Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.htmlAfter=network.targetAfter=syslog.targetFor MySQL Router...
From Oracle Support Note 2684939.1[Unit]Description=MySQL RouterAfter=syslog.targetAfter=network.targetFor Oracle Database...
[Unit]Description=Oracle Database & ListenerAfter=syslog.target network.targetsystemctl daemon-reload
Run this after each change of the unit file (i.e. the .service file).
If you don't, you will get a warning when you try to start the service.Warning: The unit file, source configuration file or drop-ins of dbora.service changed on disk. Run 'systemctl daemon-reload' to reload units.systemctl enable myservice
systemctl disable myservice
systemctl status service
journalctl -xe
To list all active units (services) that systemctl knows about...
systemctl list-units
To list only MySQL related active units...
systemctl list-units | grep mysql
To list all units that systemd has tried to load regardless of current state...
systemctl list-units --all
systemctl list-units --all | grep mysql
To list only inactive units...
systemctl list-units --all --state=inactive
To see every available unit file within the systemd paths, including those that systemd has not attempted to load...
systemctl list-unit-files
systemctl list-unit-files | grep mysql
systemctl list-dependencies myservice
Outputs a dependency tree of all units that are either required or wanted by your service.systemctl list-dependencies --all myservice
Recursively lists all dependenciessystemctl list-dependencies --before myservice
systemctl list-dependencies --after myservice
systemctl show myservice
Shows the low-level properties of your servicesystemctl show myservice -p After
Shows just the After property for your serviceTODO
systemd-analyze
systemd-analyze blame
TODO