Originally posted by Troy Morton
#!/usr/bin/ksh# Script: hcibounceprocess# Author: Troy Morton and Max Drown# Purpose: Quickly bounce a process and all its threads# Usage: hcibounceprocess # Check for correct usage#if [[ -z "$1" ]]then echo "Usage: hcibounceprocess " exit 2fiecho "Preparing to bounce process "$1" ..."## Make sure the process ($1) exists in this site#PROCESS=`hciprocstatus | grep "$1 " | awk '{print $1}'`if [[ "$PROCESS" != "$1" ]]then echo "The "$1" process was not found in $HCISITE." echo "Script aborted." exit 2fi## If the process was already down, just bring it up#STATE=`hciprocstatus | grep "$PROCESS " | awk '{print $2}'`if [[ "$STATE" = "dead" ]]then TRASH=`hcilmclear -p $PROCESS > /dev/null 2>&1` echo "The "$PROCESS" process is $STATE. Bringing it up..." TRASH=`hcienginerun -p $PROCESS > /dev/null 2>&1` STATE=`hciprocstatus | grep "$PROCESS " | awk '{print $2}'` echo "$PROCESS is: $STATE" echo "Script done." exit 1fi## Get the names of threads in this process that are up#THREADSUP=""THREADS=`hciconnstatus -p $PROCESS | tail --lines=+3 | awk '{print $2}'`for MYTHREAD in $THREADSdo MYTHREAD_STATUS=`hciconnstatus | grep " $MYTHREAD " | awk '{print $3}'` if [[ "$MYTHREAD_STATUS" = "up" ]] then THREADSUP="$THREADSUP $MYTHREAD" fidone## Stop the process#echo "Bringing down the "$PROCESS" process..."TRASH=`hcienginestop -p $PROCESS > /dev/null 2>&1`sleep 5TRASH=`hcilmclear -p $PROCESS > /dev/null 2>&1`## Restart the process and all the threads that were up when it was stopped#echo "Starting the "$PROCESS" process and the following threads :"if [[ -z "$THREADSUP" ]]then echo "NONE" TRASH=`hcienginerun -p $PROCESS > /dev/null 2>&1`else echo "$THREADSUP" TRASH=`hcienginerun -p $PROCESS -s "$THREADSUP" > /dev/null 2>&1`fisleep 5STATE=`hciprocstatus | grep "$PROCESS " | awk '{print $2}'`echo "$PROCESS is: $STATE"echo "Script done."# End of Script
Originally posted by Bob Richardson
Originally posted by Michael Hertel
Michael Hertel wrote:Right, I could put those commands into a ksh script and exec it that way.I liked the idea that I could do that as part of .cshrc.local.end
Michael Hertel wrote:
function cdr () { cd $HCIROOT/$1; }function cds () { cd $HCISITEDIR/$1; }
#!/usr/bin/kshexport CL_INSTALL_DIR=/hci/quovadx/qdx5.6eval `${CL_INSTALL_DIR}/integrator/sbin/hcisetenv -root ksh ${CL_INSTALL_DIR}/integrator $1`if [ $4 = "stop" ]then echo `hcicmd -p $2 -c "$3 pstop"` sleep 1elif [ $4 = "start" ]then echo `hcicmd -p $2 -c "$3 pstart"` sleep 1elif [ $4 = "hold" ]then echo `hcicmd -p $2 -c "$3 phold_obd"` sleep 1elif [ $4 = "release" ]then echo `hcicmd -p $2 -c "$3 prls_obd"` sleep 1else echo "Usage: threadctl.tcl "fi