Page 1 of 1

Linux startup script

Posted: Mon Mar 16, 2020 8:01 pm
by mister_v
Hi,

How do I make sure that a script is run when a server is started of restarted ?

/home/me/scripts/this.sh

Re: Linux startup script

Posted: Mon Mar 30, 2020 8:14 pm
by chris
There are several ways to run a script on startup/reboot on linux.

My favorite : Crontab

Code: Select all

sudo crontab -e
@reboot /home/me/scripts/this.sh

Another way to do it,
local.d scripts at boot time, add its init.d script to the default runlevel.

Code: Select all

Enable local.d Scripts
rc-service local start
and then create you own script in /etc/local.d/:

Code: Select all

nano /etc/local.d/myService.start
You can also create you own service,
But that is a bit more complicated.