11-02-2011 06:50 AM
I have below script to check process status of bpbkar process. The below $VALUE always returns 2 (or) 3 while executing the script, but when checking the command manually "ps -ef|grep bpbkar | grep -v grep | wc -l" on system, it returns 1. Can somebody help to fix the problem?
VALUE=`ps -ef|grep bpbkar | grep -v grep | wc -l`
if [ "$VALUE" -gt "1" ]
#echo "More than one instance of bpbkar process running"
Output of commands:-
odxcdd01:/clocal/csclvl2/user/t1707rd $ ps -ef|grep bpbkar | grep -v grep |wc -l
odxcdd01:/clocal/csclvl2/user/t1707rd $ ps -ef|grep bpbkar | grep -v grep
root 565400 1 71 23:22:33 - 44:23 bpbkar -r 604800 -ru root -dt 0 -to 0 -clnt odxcdd01.oddc.chrysler.com -class ODD_CGN_FS_AIX -sched Full -st FULL -bpstart_to 300 -bpend_to 300 -read_to 300 -ckpt_time 900 -blks_per_buffer 128 -tir -tir_plus -use_otm -fso -b odxcdd01.oddc.chrysler.com_1320204152 -kl 14 -use_ofb
11-02-2011 07:26 AM
You don't know what your matching with any assurance -- process basenames, arguments to processes and/or processes whose names contain the string "bpbkar".
A much more rigorous way to match is to use the XPG4 (UNIX95) extension with HP-UX 'ps' thusly:
# VALUE=$(UNIX95= ps -C bpbkar -opid=|wc -l)
This sets the XPG4 (or 'UNIX95') behavior only for the duration of the command line since setting it can have side-effects for other commands that you may not want or know.
The command looks for a process or processes named "bpbkar" in this example and collects the PID value. THe normal 'ps' heading line is suppressed by using the "=" suffix.
11-02-2011 10:24 PM
>but when checking the command manually
Why not put those checking commands in your script to see what it says?
Does your script have bpbkar in its name?