You can turn any script into a service or daemon via systemctl, w00t! How? See below ๐ You can use this skeletal framework when creating future daemons! Step one = create a file in the following location /etc/systemd/system/name.service and then populate it with the following below.
NOTE1: The line ExecStart=/usr/bin/env perl /path/script.pl is intended for perl scripts, you will need to put in whatever applies to you here.
Service Template
[Unit] Description=daemon name After=network.target StartLimitIntervalSec=0 [Service] Type=simple Restart=always RestartSec=1 User=root ExecStart=/usr/bin/env perl /path/script.pl [Install] WantedBy=multi-user.target
Systemctl Commands
Here are some of systemctl useful commands:
# start service sudo systemctl start SERVICE # stop service sudo systemctl stop SERVICE # restart service sudo systemctl restart SERVICE # start service automatically on system startup sudo systemctl enable SERVICE # stop service from automatically starting sudo systemctl disable SERVICE # to get a status of all services via STDOUT and no less sudo systemctl list-units --no-pager --type=service # check the status of your service sudo systemctl status SERVICE
NOTE2: To read more about the options in the config above go here.
NOTE3: To make sure your daemon resets properly fill in Restart and ResartSec. Read more here.