General
cancel
Showing results for 
Search instead for 
Did you mean: 

Startup Script to automatically start TSM deamon

Ahmed BH
Advisor

Startup Script to automatically start TSM deamon

Hi All, can anyone provide me a script to automatically recycle the TSM Client dsmc scheduler deamon?
3 REPLIES
Bill Hassell
Honored Contributor

Re: Startup Script to automatically start TSM deamon

Do you have problems with the daemon where it crashes or stops running? The brute force way to fix this is to put the program's startup command in /etc/inittab and then specifying :respawn: as the action.


Bill Hassell, sysadmin
Ahmed BH
Advisor

Re: Startup Script to automatically start TSM deamon

I have the below script:

#!/usr/bin/sh
cd /
/sbin/init.d/tsm_client &
ssh servername /sbin/init.d/tsm_client &

sleep 5

echo ===============================
echo servername2
ps -ef|grep dsm

echo ===============================
echo servername
ssh servername ps -ef|grep dsm

How can I run these commands as HP-UX boots?
Bill Hassell
Honored Contributor

Re: Startup Script to automatically start TSM deamon

This appears to be a start sequence for Tivoli and it appears that tsm_client is already in the correct location (/sbin/init.d). If the tsm_client script was written correctly, there is no reason to run the script in the background (it will always complete and should leave processes running). To see what the tsm_client did during bootup, look at /etc/rc.log.

The correct way to start tsm_client is to place a symbolic link in the /sbin/rc3.d directory, one starting with "S###" and the second link starting with "K###". The alphabetical listing of the links in rc3.d shows the order in which the S(start) scripts will run on bootup and the K(kill) scripts will run at shutdown.

The next line in your script indicates that the same script is to be run on a remote server. This seems a bit strange since I assume you have the tsm_client run during bootup on the remote machine too. Just add the symbolic links to the remote system and check the remote machine's /etc/rc.log for status. This is the normal way to start and stop applications at bootup and shutdown.

If you need to verify that a process is running, use the exact match capability of ps:

UNIX95=1 ps -fC dsm

Type the command line exactly as shown -- UNIX95=1 temporarily sets a flag for ps to use additional options. -C dsm will only find dsm and not dsm1123 or abcdsm (which is the mistake grep will make). The same is true for both local and remote commands.

So it appears that your script is required because tsm_cient is not always starting and nobody is being notified when it doesn't work. I would write a boot check script something like this:

#!/usr/bin/sh
set -u
export PATH=/usr/bin

case $1 in
'start_msg')
echo "Checking tsm_client"
exit 0
;;

'start')
CMD='UNIX95=1 ps -C dsm > /dev/null 2>&1'
# Check Tivoli locally
eval "$CMD"
RTN1=$?
if [ $RTN1 -ne 0 ]
then
echo "Check /etc/rc.log" |
mailx -s "tsm_client not running"
sysadmin@mycompany.com
fi
# Check tsm_client remotely
SERVER=servername2
ssh -n $SERVER "$CMD"
RTN2=$?
if [ $RTN2 -ne 0 ]
then
echo "Check /etc/rc.log on $SERVER" |
mailx -s "tsm_client not running at $SERVER"
sysadmin@mycompany.com
fi
if [ $ RTN1 -ne 0 ]] && exit 1
if [ $ RTN2 -ne 0 ]] && exit 1
exit 0
;;
esac

The 2 conditions in the case statement are required for all start/stop scripts. The ps command is given the UNIX95 variable to enable the -C option, but we don't need any details like -f. Instead, ps returns 0 if one or more processes with that name are found, or 1 if the process is not found. ssh -n is used when running non-interactive commands.

Place this script in /sbin/init.d with a name like tsm_check. Then make a link in /sbin/rc3.d something like:

ln -s /sbin/init.d/tsm_check /sbin/rc3.d/S999tsm_check


Bill Hassell, sysadmin