ubuntu 20.04 service autostart
Don't use User=w
, Group=w
if you need to run the script as root.
[Unit]
Description=what
After=network.target
[Service]
WorkingDirectory=/home/w/test
ExecStart=/home/w/test/whatever
KillMode=process
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=what
Restart=on-failure
RestartSec=10
[Install]
WantedBy=multi-user.target
Enable and start it:
sudo systemctl enable yourservice
sudo systemctl start yourservice
Modify your script and add:
echo "Starting my CustoM script" | logger
And after reboot check if it has been executed:
journalctl -b | grep CustoM