How to make something run on boot with systemd systems:
- Create a file named “/usr/local/bin/mything.sh” with the commands you need to run on start:
$ sudo nano /usr/local/bin/mything.sh
...
$ sudo chmod +x /usr/local/bin/mything.sh
-
Create a file called “/etc/systemd/system/mything.service”
-
In this file, put this text:
[Unit]
Description=mything: do my own thing
After=multi-user.target
[Service]
ExecStart=/usr/local/bin/mything.sh
Restart=always
StartLimitInterval=10
RestartSec=10
[Install]
WantedBy=multi-user.target
(If your thing needs the X windows GUI to be running, change all “multi-user.target” to be “graphical.target” in the above file)
- Run these two commands in a shell:
$ sudo systemctl enable mything.service
$ sudo systemctl start mything.service