Operating System - HP-UX
1767188 Members
6190 Online
108959 Solutions
New Discussion юеВ

Re: something special with hp-ux startup script ?

 
SOLVED
Go to solution
Pouponnot
Occasional Contributor

something special with hp-ux startup script ?

Hello,

I have a little problem but I can't find the solution (I don't know hp-ux very well)
In my mind, when you want start a software on unix system startup you must write a script in /etc/init.d (/sbin/init.d/bbclient under hp-ux) and create a link in /etc/rc3.d (/sbin/rc3.d/ under hp-ux).
so I have this :

# uname -a
HP-UX HP-NSR B.11.00 U 9000/879 288035332 unlimited-user license
# ls -la /sbin/init.d/bbclient
-rwxr-xr-x 1 root sys 885 Sep 13 14:47 /sbin/init.d/bbclient
# ls -la /sbin/rc3.d/S999bbclient
lrwxrwxrwx 1 root sys 21 Dec 28 2004 /sbin/rc3.d/S999bbclient -> sbin/init.d/bbclient

# cat /sbin/init.d/bbclient
#!/bin/sh
#
# Copyright (c) 1991-1999 by Sun Microsystems, Inc.
# All rights reserved.
#
#ident "@(#)Arret demarrage du client bbuser 12/03/02 AvS"
id=`/bin/ps -edf | /bin/grep bbc |/bin/grep -v bbclient|/bin/grep -v grep| /bin/awk '{print $2}'`
case "$1" in
'start')
if [ -n "$id" ]; then
echo "big brother client is already started"
else
echo "starting big brother client"
(su - bbuser -c "/home/bbuser/bbc/runbb.sh $1&")>/dev/console 2>&1
fi
;;

'stop')
if [ -n "$id" ]; then
echo "Stopping big brother client"
(su - bbuser -c "/home/bbuser/bbc/runbb.sh $1&")>/dev/console 2>&1
else
echo "big brother client is not running"
fi
unset id
;;
*)
echo "Usage: $0 { start | stop }"
exit 1
;;
esac


When I do this, all is well, the softare run:
/sbin/init.d/bbclient start
but when I do a reboot, the software don't start.
It's a basic question but under solaris and linux there is no problem.
Is there something special for startup script under hp-ux ?

Thanks a lot for your help

Julien
11 REPLIES 11
Muthukumar_5
Honored Contributor

Re: something special with hp-ux startup script ?

what is there in /etc/rc.log regarding to your bbclient script. Is it your machine run level 3?

check /etc/inittab or who -r

hth.
Easy to suggest when don't know about the problem!
Stephen Keane
Honored Contributor

Re: something special with hp-ux startup script ?

I think your link should say

/sbin/rc3.d/S999bbclient -> /sbin/init.d/bbclient

Or was the missing leading "/" on bbclient a typo?
VEL_1
Valued Contributor

Re: something special with hp-ux startup script ?


Create startup & kill files /sbin/rc3.d .

Eg:
To start the any script when reboot,

ln -s /sbin/init.d/call_script /sbin/rc3.d/S900call.rc

To kill the any script when reboot,

ln -s /sbin/init.d/call_script /sbin/rc3.d/K900call.rc

Note:
Here original file is /sbin/init.d/call_script
Marcel Boogert_1
Trusted Contributor

Re: something special with hp-ux startup script ?

Julien,

Try creating S899bbclient instead of S999bbclient.

You can also create a run-level 4 for your HP-UX server.

Check with "who -r" and change your default run-level after a reboot to 4.

Regards MB.
Mugilvannan
Valued Contributor

Re: something special with hp-ux startup script ?

May be a problem with symbolic link ?

# ls -la /sbin/rc3.d/S999bbclient
lrwxrwxrwx 1 root sys 21 Dec 28 2004 /sbin/rc3.d/S999bbclient -> sbin/init.d/bbclient

Do this,
# rm -rf /sbin/rc3.d/S999bbclient
# cd /sbin/rc3.d/
# ln -s /sbin/init.d/bbclient S999bbclient

hth.
If U need a helping hand, U will find one at the end of your arm
Fabio Ettore
Honored Contributor

Re: something special with hp-ux startup script ?

Hi Julien,

when customizing rc scripts on startup I always use /sbin/init.d/template. I should suggest you to start from the template and re-create your startup script based on that. Also it needs a configuration file under /etc/rc.config.d and I see that it's missing in your startup script.

A lot of docs about how to configure it into ITRC forum:

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=903953

HTH.

Best regards,
Fabio
WISH? IMPROVEMENT!
Peter Nikitka
Honored Contributor

Re: something special with hp-ux startup script ?

Hello,

to get feedback at startup/shutdown, you have to implement the arguments
start_msg
stop_msg

for your rc-script like
...
;;
start_smg) echo big brother client ;;

Leave this message output in your
start)-block.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Geoff Wild
Honored Contributor
Solution

Re: something special with hp-ux startup script ?

We use bb as well - here's mine:

# ll /sbin/init.d/bb
-rwxr-xr-x 1 bin bin 1578 Jun 4 2004 /sbin/init.d/bb


# cat /sbin/init.d/bb
#!/usr/bin/sh
#
# @(#) $Revision: 1.0 $
#
# NOTE: This script is not configurable! Any changes made to this
# scipt will be overwritten when you upgrade to the next
# release of HP-UX.
#

#
# Start Big Brother
#

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

rval=0
set_return() {
x=$?
if [ $x -ne 0 ]; then
echo "ERROR CODE $x"
rval=1
fi
}

case $1 in
start_msg)
echo "Starting BB monitoring."
;;

stop_msg)
echo "Stoping BB monitoring "
;;

'start')
if [ -f /etc/rc.config.d/bb ] ; then
. /etc/rc.config.d/bb
else
echo "ERROR: /etc/rc.config.d/bb defaults file MISSING"
fi

if [ "$BB" -eq 1 ]; then
su - bb -c "nohup /app/admin/bb/runbb.sh start /dev/null 2>&1" && echo bb started
set_return
else
rval=2
fi

;;

'stop')
if [ -f /etc/rc.config.d/bb ] ; then
. /etc/rc.config.d/bb
else
echo "ERROR: /etc/rc.config.d/bb defaults file MISSING"
fi

if [ "$BB" -eq 1 ]; then
su - bb -c "/app/admin/bb/runbb.sh stop" && echo bb stopped
set_return
else
rval=2
fi
;;

*)
echo "usage: $0 {start|stop}"
;;
esac

exit $rval



# cat /etc/rc.config.d/bb
#!/sbin/sh
# @(#) $Revision: 1.0 $
# BIG BROTHER configuration.
#
# BB: Set to 1 to start bb monitoring.
#
BB=1


# ll /sbin/rc*/*bb*
lrwxr-xr-x 1 root sys 12 Jun 4 2004 /sbin/rc2.d/K005bb -> ../init.d/bb
lrwxr-xr-x 1 root sys 12 Jun 4 2004 /sbin/rc3.d/S995bb -> ../init.d/bb


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Bill Hassell
Honored Contributor

Re: something special with hp-ux startup script ?

When a start/stop script doesn't seem to work, the first place to look is the start/stop log: /etc/rc.log where you'll see the start message (missing in your script) and any output from that script.

There are actually two files to create: the start/stop script and the configure script. The configure script is stored in /etc/rc.config.d and usually named the same as the start/stop script. In it's simplest form, the configure script might just say:

BBRUN=1

and then in your start/stop script, you would test for BBRUN=1 to start the program (never test for BBRUN=1 for stopping it since it may be running and if you change BBRUN=0 for the next reboot, it won't be stopped during shutdown.

The line:

id=`/bin/ps -edf | /bin/grep bbc |/bin/grep -v bbclient|/bin/grep -v grep| /bin/awk '{print $2}'`

might be somewhat protable between flaors of Unix but it is an awful way to find a process by name. It will return programs like bbc1 and userbbc and bbbccc. HP-UX has a very powerful ps command that eliminates grep completely and simplifies getting the details you want by using -o. Replace the id line above with:

id=$(UNIX95= ps -C bbc -o pid=)

This will have either an empty string (id="") if not bbc process is found, or a list of all the copies of bbc (b ut not bbcclient, etc).

I have attached a heavily documented template file you can use to build a good start/stop script.


Bill Hassell, sysadmin