Main / Systemd
In 2021, systemd is considered the newer service control methodology for various Linux distros. It replaces initd. Create a .service file for your service in /etc/systemd/system. Here is a working example that runs socat: [Unit] Description=automation of socat forwarders with relayd After=network.target StartLimitIntervalSec=0 [Service] Environment="FMS_PLAT_UDPPORT=3996" Environment="PLAT_FWD_UDPPORT=3998" #Airbus FMS machine IP Environment="FMS_IPADDR=127.0.0.1" #which interface to use on this machine for connecting to Foo network Environment="FOO_LOCAL_IPADDR=127.0.0.1" #which interface to use on this machine for connecting to Bar network Environment="BAR_LOCAL_IPADDR=127.0.0.1" User=optimus WorkingDirectory=/home/optimus Restart=always RestartSec=5 Type=simple #Type=oneshot #Type=forking ExecStart=socat -d -d UDP-LISTEN:${PLAT_FWD_UDPPORT},bind=${AAC_LOCAL_IPADDR},fork,reuseaddr UDP:${FMS_IPADDR}:${FMS_PLAT_UDPPORT},bind=${AIRBUS_LOCAL_IPADDR} [Install] WantedBy=multi-user.target Whenever you make a change to a service file, run systemctl daeomon-reload to pick up changes to the system folder. You can then run with sudo systemctl start <myservname>.service and read logs with sudo journalctl -f -u <myservname>.service |