Operating System - Linux
1757782 Members
2705 Online
108863 Solutions
New Discussion юеВ

Run script when system reboot

 
SOLVED
Go to solution
juno2
Super Advisor

Run script when system reboot

I want to run some scripts when everytime the linux server reboot, when file should I modify ? I use RH 8 . thx





6 REPLIES 6
Cristian Draghici_1
Frequent Advisor

Re: Run script when system reboot

If you mean __after__ the system boots, look into /etc/rc.local or see chkconfig for editing start and stop for system services.

In Rh9.0 there's a gui tool called redhat-config-services, see if you have that.

All the service stubs are located in /etc/rc.d/init.d.

Good luck,
Cristi
juno2
Super Advisor

Re: Run script when system reboot

Thx reply,

how about /etc/inittab ? is it also run the script in the file when reboot ? thx
Alexander Chuzhoy
Honored Contributor

Re: Run script when system reboot

the inittab file isn't the right place for scripts.
use /etc/rc.local
Cristian Draghici_1
Frequent Advisor
Solution

Re: Run script when system reboot

Inittab is somewhat a lower level than what you're looking for.

You can use inittab to configure the runlevel in which your system runs (e.g. 5 for graphical, 3 for non-graphical).

See 'man inittab' for the complete description.

HTH
Cristi
Huc_1
Honored Contributor

Re: Run script when system reboot

Could you be more specific, the reason I am asking is because you may want to stat someting very early in the system startup

like during boot ... before some services are started ... or after in short do you require that some of the enviroment be there or not ?

what you want to execute pretty much determine what file you should modify.

Jean-Pierre
Smile I will feel the difference
Steven E. Protter
Exalted Contributor

Re: Run script when system reboot

The following applies to all the unix systems I've ever touched, there are variations, but they are not significant.

Linux

/etc/init.d

The location of all startup scripts

/etc/rc#.d

There are usually 6 of these numbered zero through five, assumming your system(prior posts) is a run level 5 system.

What you do to get things to run at startup is place softlinks in these directories pointing at scripts in /etc/init.d

Example

I have a script that starts the bagel service.

/etc/init.d/bagel

This script follows a standard format requiring start or a stop or a restart as the first command line parameter.

To get it to start at run level five:

ln -s /etc/init.d/bagel /etc/rc5.d/S85bagel

the capital S is critical, everthing else is documentation

If you start it you want to stop it usually one run level below where you start it.

ln -s /etc/init.d/bagel /etc/rc4.d/K85bagel

S for start

K for kill

all you need now is some real scripts to run.

Be careful what you run, you system will not be fully operational until its done.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com