PDA

View Full Version : Linux, how to run script/commands on linux server boot



Fli
09-02-2013, 10:29 AM
You can do:

chkconfig servicename on
on rhel or on ubuntu:
sudo update-rc.d servicename defaults

or if its not service, you can add commands manually into file called /etc/rc.local above exit 0 line

vi /etc/rc.local

hit "a" key and move to empty line before exit 0 then write your commands line by line

stop editing by Ctrl + C
save changes by executing: :wq
discard changed by executing: :q!

or

create startup script in /etc/init.d/

for example: vi /etc/init.d/mystartup

- insert commands
- save

add execute permissions:

chmod +x /etc/init.d/mystartup

set this script to execute on boot:

sudo update-rc.d mystartup defaults



--- If softwares, scripts still dont launch on boot, try this:

modiffy permissions to the rc.local file:

chmod u+x /etc/rc.local

Also try to add full path to the scripts like /usr/bin/perl not perl

Also try replacing text. #!/bin/sh -e by #!/bin/sh in rc.local