Skip to content

Generic systemd service

wiedehopf edited this page Feb 16, 2020 · 1 revision

Assuming the executable is at this path: /usr/local/bin/mybinary (modify the ExecStart line to match your executable path)

The service name is myservice, you will need to change various lines if you want a service with a different name. Search for myservice so you know what needs to be changed for the service you want to create.

sudo nano /lib/systemd/system/myservice.service

paste this:

[Unit]
Wants=network.target
After=network.target

[Service]
EnvironmentFile=/etc/default/myservice
SyslogIdentifier=myservice
ExecStart=/usr/local/bin/mybinary $OPT1 $OPT2 $OPT3 $OPT4
Type=simple
Restart=always
RestartSec=10

[Install]
WantedBy=default.target

then:

sudo nano /etc/default/myservice

paste this:

OPT1="-v -o 4 -i KK-ABCDEF-ACARS -j feed.acars.io:5550"
OPT2="-r 0 131.550 131.525 131.725 131.825 130.025 130.425 130.450 131.125"
OPT3=""
OPT4=""

Then enable and start the service:

sudo systemctl enable --now myservice

Check the log associated with the service (Ctrl-C when you are done watching the output)

sudo journalctl -u myservice -n100 -f
Clone this wiki locally