Systemd

General commands

#start a service
$systemctl start service.service
#stop a service
$systemctl stop service.service
#status of a service
$systemctl restart service.service

Create a service systemd

Create a file

$nano /etc/systemd/system/some_script.service

some_script.service

[Unit]

Wants=network-online.target

After=network.target network-online.target

[Service]

ExecStart=/root/script/some_script.sh

[Install]

WantedBy=default.target

Enable service via systemd

#set the good permissions
$chmod 744 /root/script/some_script.sh
#reload the daemon
$systemctl daemon-reload
#enable the service at startup
$systemctl enable some_script.service

Test your service

$systemctl start  some_script.service

Debug a service

#debug for the service "SERVICENAME.service"
$journalctl -u SERVICENAME.service

Date : 2017.06.12