Ubuntu systemd start-up script

2017-12-07 13:39:31 Using Computers Ubuntu
  1. Create a script, e.g. /root/startup.sh.
  2. Create a service in `/etc/systemd/system’, e.g. ‘/etc/systemd/system/startup.service’
  3. Edit the service:
[Unit]
Description=Startup Script

[Service]
Type=oneshot
ExecStart=/root/startup.sh
WorkingDirectory=/root

[Install]
WantedBy=multi-user.target

Lastly, run systemctl enable startup.service

Reboot and test.

Tips:

  1. Before adding the service, run the script to confirm that it works
  2. Before reboot, use service [name] start to confirm that it works