Simple service
To create a simple service. First enter system’s service folder.
cd /lib/systemd/system
Create a file named after you service
touch <your-service-name>.service
Template for service
[Unit]
Description=<description about this service>
[Service]
User=<user e.g. root>
WorkingDirectory=<directory_of_script e.g. /root>
ExecStart=<script which needs to be executed>
Restart=always
[Install]
WantedBy=multi-user.target
After you added your service file you may need to reload systemd-daemon
systemctl daemon-reload
After the daemon has been reloaded you can start your service
systemctl start <your-service-name>.service
If you want your service to start on boot you can enable it
systemctl enable <your-service-name>.service