How to run a shell script at startup
علی ذوالفقار
1399/03/09 22:55:19 (6)
create your script in /etc/init.d : 
	sudo nano /etc/init.d/NameOfYourScript

Make script executable
	sudo chmod 755 /etc/init.d/NameOfYourScript
Register script to be run at start-up : 
	sudo update-rc.d NameOfYourScript defaults
If you ever want to remove the script from start-up, run the following command :
	sudo update-rc.d -f  NameOfYourScript remove
or try this via Set a crontab for your .sh file (file must be executable) : 
	#crontab -e
	@reboot  /home/user/

i found this solution on stackoverflow too : Enter cron using sudo: sudo crontab -e Add a command to run upon start up, in this case a script: @reboot sh /home/user/ Save: Press ESC then :x to save and exit, or hit ESC then ZZ (that's shift+zz) Run your test script without cron to make sure it actually works. Make sure you saved your command in cron, use sudo crontab -e Reboot the server to confirm it all works sudo @reboot