There are multiple ways you can execute a script or command on startup in Linux.
Using crontab:
1 2 3 4 5 6 7 8 9 |
## Create a new entry in crontab sudo -i crontab -e ## Update below entry in your crontab @reboot sh /some/path/to/your/script.sh ## Make use your script has execute permisison chmod +x /some/path/to/your/script.sh |
Using rc.local:
1 2 3 4 |
## Appned your script path to rc.local and give execute permission sudo -i echo "/some/path/to/your/script.sh" >> /etc/rc.d/rc.local chmod +x /etc/rc.d/rc.local |
Using init.d:
1 2 3 4 |
## Put your script inside init.d and give execute permission sudo -i cp /some/path/to/your/script.sh /etc/init.d/ chmod +x /etc/init.d/script.sh |