Operating System - Linux
1827894 Members
1459 Online
109969 Solutions
New Discussion

Re: start service when bootup

 
SOLVED
Go to solution
peterchu
Super Advisor

start service when bootup

I want to run the script when system boot up , I tried to add to the file /etc/inittab like below , but still can't do that , could suggest what is wrong ? thx.

MFG1:3:once:/home/EE/startdb
5 REPLIES 5
Roberto Polli
Trusted Contributor
Solution

Re: start service when bootup

You have 2 ways:
1) add a row to inittab specifying:
mscl:23456:once:/path/to/script

where "
mscl - label
23456 - list of runlevels where tu run file
once - run this file once

and then reload inittab issuing
#init q

2) if the script is a kind of service you may prefer to copy the script in /etc/init.d adding the following lines at the beginning of the file:
---begin quote---
#
# chkconfig: 235 99 02
#
---end quote---
The chkconfig manual says:

This says that the random script should be started in levels 2, 3, 4,
and 5, that its start priority should be 99, and that its stop priority
should be 02.

Then tell to the system to start this file at boot:
#chkconfig FILENAME on

Then the system will issue a
#/etc/init.d/FILENAME start
after processing all files in /etc/rc?.d/ with start priority less than 99
and a
#/etc/init.d/FILENAME stop
after processing all files in /etc/rc?.d/ with stop priority less than 02

for further info
#man chkconfig
#man inittab
Peace, R
Shaikh Imran
Honored Contributor

Re: start service when bootup

Hi,
I don't have idea about the linux but maybe what you are doing is wrong.
In hp the configuration file is kept in /etc/rc.config.d/filename.
The execution scripts are in /sbin/init.d/filename and this (execution script) is linked to /sbin/rc3.d/S340filename
where S=start 340 = sequence
Similarly
The same script will be linked to
/sbin/rc2.d/K560filename
This will kill the service while restarting.


The above concept is tru for any unix but the directories are different.
I'll sleep when i am dead.
Roberto Polli
Trusted Contributor

Re: start service when bootup

If you have some strange libs you may use onli 2 chars in the unique id field.

Try to
mf:3:once:/home/EE/startdb

and end file with a nice

Peace, R.

Michael Williams_6
Trusted Contributor

Re: start service when bootup

Hi Peter,

Just a quick thought, but I notice that your script is in /home, normally this would be a filesystem all of its' own, if this is the case, you will want to make sure that this filesystem is mounted before it is run in the inittab. This is especially true if it's an NFS mount, like our homes as this isn't mounted until networking is started!

Just a thought!
Claudio Cilloni
Honored Contributor

Re: start service when bootup

the file /etc/rc.d/rc.local (in Redhat machines) is executed after the startup sequence. you can add your commands in this file in order to execute them at every boot.

hth,
Claudio