Create systemd service on Linux machine

From AcrodusWiki

This is a note on how to create a systemd service based on a c program. This was created after implementing the genisys echo detection program as a systemd service.

The first thing is to make a Unit file. An example is shown below.

[Unit] Description=Detect genisys echo. After=network.target [Install] WantedBy=multi-user.target [Service] Type=simple ExecStart=/home/alex/Programs/echo_detection/echo_detection WorkingDirectory=/ Restart=always RestartSec=5 StandardOut=syslog StandardError=syslog SyslogIdentifier=%n

Note this will redirect stdout to syslog so just make sure everything is ok.

Now put this file into /etc/systemd/system. Run the command sudo systemctl daemon-reload. Then enable and start the service.