1834208 Members
2637 Online
110066 Solutions
New Discussion

Init Run Levels

 
SOLVED
Go to solution
Dennis Handly
Acclaimed Contributor

Re: Init Run Levels

>when I move from level 3 to 2 - only the K script of level 3 should be invoked - isn't it?

That's not what it says:
If a transition from a higher to a lower run level occurs, the kill scripts for the new run level and all intermediate levels between the old and new level are executed.

So from 3 to 2, only 2 gets executed.
devshlom
Regular Advisor

Re: Init Run Levels

ok....
so, the K script on level 2 should be executed, when I moved from 3 to 2.
what can cause it not to be executed?!

tx
Dennis Handly
Acclaimed Contributor

Re: Init Run Levels

>what can cause it not to be executed?

You need to trust in the rc(1m). :-)
Take a look at /etc/rc.log.
Steven E. Protter
Exalted Contributor

Re: Init Run Levels

Shalom,

To execute a Kill init script run level 2.

init 2

or reboot

To execute a Start script run level 3

reboot

or

init 3

Note a softlink in /sbin/rc3.d/s180oracle will not execute

/sbin/rc3.d/S180oracle
will execute.

There is no chkconfig command in HP-UX.

lets say S180oracle softlinks to /sbin/init.d/oracle

For diagnostics , throw some echo statements in that script to try and narrow down the problem.

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
devshlom
Regular Advisor

Re: Init Run Levels

ok guys,
I found the problem, now I need the way to solve it.

Since my service is a networking server, before I start it or stop it I check its status, by the command "ps -ef | grep -i $BIN_FILE_PATH | grep -v grep | awk '{print $2}'"

this is working for all the Unix platforms and also here when running from the command line.
BUT, after reading the rc log, I saw the following error:


Output from "/sbin/rc2.d/K009aim stop":
----------------------------
/sbin/rc2.d/K009aim[2]: ps: not found.
/sbin/rc2.d/K009aim[2]: grep: not found.
/sbin/rc2.d/K009aim[2]: grep: not found.
/sbin/rc2.d/K009aim[5]: printf: not found.

why those commands are not recognized?!
I'm sure there is something I miss here.

tx






Dennis Handly
Acclaimed Contributor

Re: Init Run Levels

>after reading the rc log, I saw the following error:
/sbin/rc2.d/K009aim[2]: ps: not found.
/sbin/rc2.d/K009aim[2]: grep: not found.
/sbin/rc2.d/K009aim[5]: printf: not found.

This is why I mentioned using "env -i".

>why those commands are not recognized?

Either your PATH isn't set up. Or /usr/bin is no longer mounted so you can't use those commands. Only the ones in /sbin/.
None of these commands are in /sbin/. So if your sequence number is before /usr is mounted, you'll fail.

Your K009aim seems to indicate you would be near the first for "K".
devshlom
Regular Advisor

Re: Init Run Levels

TX MEN...
I've already figured it out.
In my aim script I shoulf set the PATH variable and that fixed all the problem....


now...
after everything work, I want to get back to standards.
Is it ok to put K script only on rc2.d and S script on rc3.d
The reason that I'm asking is since on the other platforms, for each level that the server should be up/down we put the relevant script.

but here - I wonder.... what do you say?

Dennis Handly
Acclaimed Contributor

Re: Init Run Levels

>Is it ok to put K script only on rc2.d and S script on rc3.d

This is not "ok" but this is required that you have it S for 3 and K for 2.

>for each level that the server should be up/down we put the relevant script.

rc(1m) says that all levels between are executed. This basically means if you only have it in one place, you only do it on S transitions to 3 or higher. Or on K transitions to 2 or lower. You don't need it at every level, unless you want to do different things.
James R. Ferguson
Acclaimed Contributor

Re: Init Run Levels

Hi:

> In my aim script I shoulf set the PATH variable and that fixed all the problem....

If you had started with the '/sbin/init.d/template', or looked at it more closely, you might have seen :-) that it declares a minimal PATH:

PATH=/usr/sbin:/usr/bin:/sbin

Too, when you test startup and shutdown (kill) scripts at a commandline, and they work, but then fail when executed in the '/sbin/rc?.d' sequence during changes in 'init' level, you can immediately begin to suspect deficiencies in your running environment. Aside from the PATH, you must include any environmental variable that you need. This is the reason I suggested that you test first at the command line in your normal shell environment.

Regards!

...JRF...

devshlom
Regular Advisor

Re: Init Run Levels

tx all