Operating System - HP-UX
1830241 Members
1457 Online
109999 Solutions
New Discussion

Auto Start script question

 
SOLVED
Go to solution
John Sutton
New Member

Auto Start script question

Hi,
I grabbed one of the auto start scripts from /sbin/init.d and altered it to start Tivoli upon reboot for me. My problem is that when it starts, it writes the backup log to the /etc/rc.log which I do not want. It also logs in the proper placedsmsched.log), I don't need the logging in the rc.log.
Thanks in advance for any help.
7 REPLIES 7
Patrick Wallek
Honored Contributor

Re: Auto Start script question

If you upload the start script, it would be a big help.
Steven E. Protter
Exalted Contributor

Re: Auto Start script question

Most hp depots come with their own start scritps.

For products that don't you may wish to start with a copy of template in /sbin/init.d

Its a good starting point.

Please upload the script.

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
Bill Hassell
Honored Contributor

Re: Auto Start script question

The output from a start/stop script is logged into /etc/rc.log and should only contain success/failure info. Apparently, the Tvoli commands you are using are dumping these logs to stdout. If you run the Tivoli startup commands, do you see backup log?


Bill Hassell, sysadmin
Michael Schulte zur Sur
Honored Contributor

Re: Auto Start script question

Hi,

you might want to reroute the output of the start script of tivoli to some place else.

greetings,

Michael
John Sutton
New Member

Re: Auto Start script question

I am posting the script, Hope it shows up legible. Thank you for the help.


PATH=/sbin:/usr/sbin:/usr/bin:/opt/tivoli/tsm/client/ba/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 "Start Tivoli server daemon"
;;
stop_msg)
echo "Stopping Tivoli server daemon"
;;
'start')
if [ -f /opt/tivoli/tsm/client/ba/bin/dsmc ] ; then
cd /tiv nohup /opt/tivoli/tsm/client/ba/bin/dsmc schedule &
else
echo "ERROR: /opt/tivoli/tsm/client/ba/bin/dsmc file MISSING"
fi
rval=2
;;
'stop') #
# Determine PID of process(es) to stop
#
pid=`ps -ef|grep dsmc|grep -v grep |awk '{print $2}'`
if [ "X$pid" != "X" ]; then
if kill $pid; then
echo "Tivoli daemon stopped"
else
set_return
echo "Unable to stop Tivoli daemon
fi
fi
;;

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

exit $rval
R. Allan Hicks
Trusted Contributor

Re: Auto Start script question

Looks like a standard start script. I have legato and start it on boot up. Never noticed anything in my rc.log.

What happens if you run the script

/sbin/init.d/script start


This is the networker file that legato installed

#!/sbin/sh
# installed by postinstall on Wed Nov 19 16:59:06 EST 2003
#
# Default locale
#
LANG=C
export LANG

# Override to a different locale if /usr/lib/nsr/LANG exist
[ -r /usr/lib/nsr/LANG ] && . /usr/lib/nsr/LANG

case $1 in
'start_msg')
echo 'Starting Networker daemons'
;;
'stop_msg')
echo 'Stopping Networker daemons'
;;
'start')
(echo 'starting NetWorker daemons:') >> /etc/rc.log
if [ -f /opt/networker/bin/nsrexecd ]; then
(/opt/networker/bin/nsrexecd) >> /etc/rc.log 2>&1
(echo ' nsrexecd') >> /etc/rc.log
fi
if [ -f /opt/networker/bin/lgtolmd ]; then
(/opt/networker/bin/lgtolmd -p /nsr/lic -n 1) >> /etc/rc.log 2>&1
(echo ' lgtolmd') >> /etc/rc.log
fi
if [ -f /opt/networker/bin/nsrd -a ! -f /opt/networker/bin/NetWorker.clustersvr
]; then
(/opt/networker/bin/nsrd) >> /etc/rc.log 2>&1
(echo ' nsrd') >> /etc/rc.log
fi
;;
'stop')
(echo 'stopping NetWorker daemons:') >> /etc/rc.log
if [ -f /opt/networker/bin/nsr_shutdown ]; then
if [ -f /opt/networker/bin/NetWorker.clustersvr ]; then
(/opt/networker/bin/nsr_shutdown -c -a -q&) >> /etc/rc.log 2>&1
(echo ' nsr_shutdown -c -a -q') >> /etc/rc.log
else
(/opt/networker/bin/nsr_shutdown -a -q&) >> /etc/rc.log 2>&1
(echo ' nsr_shutdown -a -q') >> /etc/rc.log
fi
fi
;;
*)
echo "usage: `basename $0` {start|stop}"
;;
esac

I only get the start and stop messages. Networker sends its annoying crap to the console.

Hope this helps

"Only he who attempts the absurd is capable of achieving the impossible
Bill Hassell
Honored Contributor
Solution

Re: Auto Start script question

A couple of notes:

The logging code is being produced by the command:

/opt/tivoli/tsm/client/ba/bin/dsmc schedule

If you run this from a shell prompt and it does not produce a log listing, then the environment is triggering the log dump. You'll need to explicitly create the same environment during start-up since start-up doe NOT login and run any profiles. To see how different the login environment is from the start-up environment, save the output of the env command from a login prompt and add env to your start script. Just add the missing items to your start script.

As far as starting and stopping, here are a couple of suggestions:

1. Rather than check the executable as a file (-f option), use the -x instead. This verifies that the executable exists and is also executable.

2. Searching for a process using grep can produce very ambiguous results since grep does not look at the process name--it looks at everything on the line including user names and command line arguments. Elimnate the ambiguiy by letting ps search for you (it's much faster). Change the lines:

pid=`ps -ef|grep dsmc|grep -v grep |awk '{print $2}'`
if [ "X$pid" != "X" ]; then
if kill $pid; then
echo "Tivoli daemon stopped"
else
set_return
echo "Unable to stop Tivoli daemon

to:

PID=$(UNIX95= ps -C dsmc -o pid | tail -1)
if [ $PID = PID ]
then
echo "Tivoli dsmc not running"
else
if kill $PID
then
echo "Tivoli daemon stopped"
fi
fi

The construct "UNIX=95 ps" activates a large number of additional parameters for ps including -C -H and -o. -o is particularly useful as you can specify exactly what you want from ps. If the process is not found, just the text "PID" is returned, otherwise, the PID for the last occurance of dsmc will be returned. In the above code, you can test it using everything inside the parens $() (which is strongly preferred over backtics or grave accent (see man page for sh-posix or ksh). For instance, these two constructs produce very different results:

ps -ef | grep sh | grep -v grep

UNIX95= ps -fC sh

The second form is accurate because ps looks at the process table by name, not by grep'ing a bunch of unrelated fields.


Bill Hassell, sysadmin