systemd unit files

Starting scripts with systemd

It's super simple to set up a service in system that starts when you say so, or automatically on boot.

create a .service file in /etc/systemd/system named myservicename.service


ExecStart=/bin/bash /home/scipts/
SyslogIdentifier=myservicename # without any quote


once saved, reload the unit files

# systemctl daemon-reload

and start the service

# systemctl start myservicename

to stop

# systemctl stop myservicename

to check status

systemctl status myservicename

and last but not least, to enable a service on next boot

systemctl enable myservicename

to view logs:

journalctl is used to view logs on systemd based machines, Logs are identified by the SyslogIdentifier it can be changed to anything you'd like. SyslogIdentifier in this example is myservicename. -f is used to follow, like tail.

journalctl -u myservicename -f