[SOLVED] first file which is executed when we reboot or shutdown Linux server
Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
The commands themselves work, I can see the links created, but my Oracle instance never seems to startup or shutdown properly.
Thus, I was trying it to start/stop Oracle at startup/shutdown by two ways:-
1) Through chkconfig which eventually makes S* and K* are soft links only.
I have also posted this link in "Linux General" forum.
2) Also, I was looking for other way round like to put a script when machines is just about to go off. I am sure there must be a way.
Learning is my motive . I want to learn it both ways, through chkconfig method as well as put a script/command in a system file which executes just in the starting of reboot or shutdown process.
That makes this thread half crosspost and half not. Wrt symlinks SysV init works like that so if you've got problems with your init scripts I suggest you fix those first before trying to find workarounds that conflict with doing things the RHEL way.
That makes this thread half crosspost and half not. Wrt symlinks SysV init works like that so if you've got problems with your init scripts I suggest you fix those first before trying to find workarounds that conflict with doing things the RHEL way.
But, still just for sake of knowledge I looking for something similar to /etc/rc.d/rc.local for reboot & shutdown.
OK. What application does 'shutdown' send a signal to on shutdown? Which configuration file does that other process use by default to handle runlevel changes? Would it be possible to add another line that could drive a process on entering runlevel 6?
OK. What application does 'shutdown' send a signal to on shutdown? Which configuration file does that other process use by default to handle runlevel changes? Would it be possible to add another line that could drive a process on entering runlevel 6?
hey, so many questions.
I did not knew my query would drive so many questions in turn !
this did not clicked on my mind. Will try it and update you with the results.
True, but it does make me wonder how you can have a RHCE and be a "linux administrator" without knowing the most basic of basics (or how to find out for for yourself for that matter)...
True, but it does make me wonder how you can have a RHCE and be a "linux administrator" without knowing the most basic of basics (or how to find out for for yourself for that matter)...
It is my fault. I did not read your questions properly. I should have been more attentive to them.
NP, happens to me too sometimes. Anyway, did you figure out how to make this work?
Thanks unSpawn,
Well I got some good learning too reviewing /etc/inittab. I must admit, I did not paid required attention this file needed. Rather, till now I did not felt the need.
This worked out for me. I can modify the below lines of /etc/rc.d/rc
Code:
# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
check_runlevel "$i" || continue
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/K??}
[ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
|| continue
# Bring the subsystem down.
if egrep -q "(killproc |action )" $i ; then
$i stop
else
action $"Stopping $subsys: " $i stop
fi
done
as here
Code:
# First, run the KILL scripts.
for i in /etc/rc$runlevel.d/K* ; do
check_runlevel "$i" || continue
if [ $runlevel -eq 0 ] || [ $runlevel -eq 6 ];
then
my script or my commands
fi
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/K??}
[ -f /var/lock/subsys/$subsys -o -f /var/lock/subsys/$subsys.init ] \
|| continue
# Bring the subsystem down.
if egrep -q "(killproc |action )" $i ; then
$i stop
else
action $"Stopping $subsys: " $i stop
fi
done
I believe this should work. Thanks a ton for your patience and time.
Last edited by vikas027; 08-31-2009 at 12:50 PM.
Reason: Added a space after $runlevel
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.