User Tools

Site Tools


create_a_service_via_systemd

Systemd general commands

Here alls command on Systemd


  • Command for start / stop / status

systemctl start service.service
systemctl stop service.service
systemctl restart service.service


  • Create a service

In terminal, modify :

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

Add the following example :

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 script with daemon :

$chmod 744 /root/script/some_script.sh
$systemctl daemon-reload
$systemctl enable some_script.service

Test your script :

$systemctl start  some_script.service


  • Debug a service

In terminal :

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


- modified date : 2017.06.12 -

create_a_service_via_systemd.txt · Last modified: 2017/06/12 17:06 (external edit)