GNU+Linux command memo

Run a command at startup

Lancer une commande au démarrage.

- via rc.local

# vi '+%s/^exit 0/$cmd\rexit 0/' +:wq /etc/rc.local (1)
1 Add your command before the exit 0 in the /etc/rc.local file of your system.

- via crontab

# echo "@reboot $cmd" >> /etc/crontab  (1)
1 crontab can starts commands at startup with the special keyword @reboot. See man 5 crontab.

- or via systemd

Create a /lib/systemd/system/$name.service file :

Description=My startup time service
# chmod u+x /path/to/sbin/ (1)
# systemctl start $name.service (2)
# systemctl enable $name.service (3)
1 Make the script en executable one
2 Start the service, it will execute the script once
3 Enable the service, to make it starting at each reboot

See man systemd.unit for more info.