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

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

Cara restart / stop windows service (services.msc) dengan bat / cmd

How to convert VMDK to OVA