Create systemd service on Linux machine

From AcrodusWiki
Revision as of 21:34, 6 October 2024 by Alex (talk | contribs) (Created page with "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=sy...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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.