how to run script at boot using systemd

Example I have script to run at boot

Create your own script, my example is start-myscript.sh

Make that the script executable with:

chmod u+x /usr/local/bin/start-myscript.sh

And then create a file named end with .service, this file will be used to call the start-myscript.sh, example: myscript.service file should look like this:

[Unit]
Description=My Script

[Service]
ExecStart=/usr/local/bin/start-myscript.sh

[Install]
WantedBy=multi-user.target

Now do a few more steps to enable and use the .service file:

Place it in /lib/systemd/system folder with say a name of myscript.service

Start it:

sudo systemctl start myscript

Enable it to run at boot:

sudo systemctl enable myscript

Stop it:

sudo systemctl stop myscript

Komentar

Postingan populer dari blog ini

Cara memahami dan menghafal model OSI dengan analogi

Pembahasan IT Network Systems Administration Module A DNS (Forward Zone, Reverse Zone, CNAME, MX, Split View)

Table of Contents