Skip to content

Start script on startup ​

Create your script ​

create your script with shebang on top

sh
# myscript.sh
!#/bin/bash
echo "AAAAA"

Create service files ​

Create your myawesomeservice.service like /etc/systemd/system/myawesomeservice.service the .service and the end of file are required!

[Unit]
Description=Service desc.

[Service]
Type=simple
User=otheruser # not required just a note for me on how to run script as other user.
ExecStart=/bin/bash /path/to/my/script.sh

[Install]
WantedBy=multi-user.target

chmod and final command ​

sh
chmod 644 /etc/systemd/system/myawesomeservice.service
systemctl enable myawesomeservice.service