Linux startup script

All questions related to servers
Post Reply
mister_v
Posts: 167
Joined: Thu Mar 04, 2010 9:19 pm

Linux startup script

Post 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

chris
Site Admin
Posts: 170
Joined: Mon Jul 21, 2008 9:52 am

Re: Linux startup script

Post 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.

Post Reply