How to use systemd to run a startup script on boot

This example shows how to start a script when multi-user is launched.

Create a new file in /etc/systemd/system [e.g. myscript.service] and add the following content:

Description=My Script



Put your script in /usr/bin/my-script and make sure it’s executable.

sudo chmod 755 /usr/bin/my-script

Then enable the service:

sudo systemctl enable myscript.service