Operating System - HP-UX
1835242 Members
2118 Online
110078 Solutions
New Discussion

Re: simulate reboot for rc scripts

 
SOLVED
Go to solution
Michael Murphy_2
Frequent Advisor

simulate reboot for rc scripts

Hello,

I am constantly having problems running third party software out of rc scripts (or really NOT running - they never seem to start correctly). My current attempts have been trying to start tomcat under a user other than www or root - 4 weeks of reboots trying to get the syntax (su's, nohups, backgrounds) right. These same scripts always run OK from the command line. Any way to simulate a reboot (from the command line - without restarting the machine) for rc scripts so that they can be tested during working hours???
3 REPLIES 3
A. Clay Stephenson
Acclaimed Contributor

Re: simulate reboot for rc scripts

You can run the scripts individually quite easily:

Let's say that you a script mycmd in /sbin/init.d symbolically linked to ../rc3.d/S900mycmd and to ../rc2.d/K100mycmd.

To run the command manually,
/sbin/init.d/mycmd start
to stop it:
/sbin/init.d/mycmd stop

Do this in the lexical order of the commands under the rcN.d directories and you should simulate well. The one "gotcha" is that running interactively like this you are still associated with a controlling terminal so that the emulation is not perfect. In my humble (more or less) opinion, rc scripts which rely upon nohups and backgrounds were not written very well in the first place. Perl has very nice built-ins (fork(),setsid(),nice signal handling) to properly "daemonize" processes.
If it ain't broke, I can fix that.
Todd McDaniel_1
Honored Contributor
Solution

Re: simulate reboot for rc scripts

Actually, I use rc4.d and rc3.d for this...

Link the /sbin/init/d./myscript to rc4.d for SXXXmyscript.sh to start and to rc3.d for KXXXmyscript.sh to kill

Then execute init 4, to see if it runs... then init 3 to return to your normal runlevel.

rc4.d is great for testing!!!
Unix, the other white meat.
curt larson_1
Honored Contributor

Re: simulate reboot for rc scripts

I'd say go into /sbin/rc to find out what the environment is at startup. put a

file=/tmp/env
set > /tmp/env
stty -a >/tmp/stty

then unset all the variables and aliases in your environment. source in /tmp/env. source in /etc/rc.config. then run your startup script /sbin/init.d/Sxxxyourscript start.

this should get you pretty close. But as Mr. Stephenson points out because of the controlling terminal you'll need to be carefull in how you select your TERM and stty settings.

I suppose if you wanted to go far enough. You could do the above from the command line on the system console.