1830041 Members
1689 Online
109998 Solutions
New Discussion

check the process

 
addendum
Advisor

check the process

I want to find the pid ( by ps ) that has already run over 30 seconds , I know ps only show the minute/hour .

eg. the start time of the below process are 15:19 / 15:20 , but I don't know the exact time ( in term of "second" ) it start to run ( I only know the hour and minute ) , if I want to find which of these jobs that it has started to run over 30 seconds ( it should be 8212 , 8215 , 8221 ) , what can I do ? thx


#ps -ef |grep ora

root 8212 1 0 15:19 ? 00:00:00 ora
root 8215 1 0 15:20 ? 00:00:00 ora
root 8221 1 0 15:20 ? 00:00:00 ora
root 8224 1 0 15:20 ? 00:00:00 ora

#date
Mon Sep 26 15:20:35 CST 2005
4 REPLIES 4
RAC_1
Honored Contributor

Re: check the process

UNIX95= ps -uoracle -o etime= -o pid= -o ruser= | grep -i [o]ra

If etime (the format seems to be MM:SS) is greater than 30 secs, you can do what you want.
There is no substitute to HARDWORK
Muthukumar_5
Honored Contributor

Re: check the process

You can get as,

# UNIX95= ps -eo comm,pid,etime | awk '{ split($3,a,":"); time=a[1]*60 + a[2]; if ( time > 30 ) { print $2" is running more than 30 seconds" }}'

hth.
Easy to suggest when don't know about the problem!
addendum1
New Member

Re: check the process

thx Muthukumar 's help much ,

If I want to merge the above condition with the script you provide , could suggest how to change it ? thx

#!/bin/ksh
# unuse.ksh
# Time to Sleep - 60 seconds / 10 times = 6 second
stime=6

while [ 1 ]
do
for pid in `ps -ef | grep -i 'ora' | awk '!/COMMAND/ { if ( $3 != "2" ) { print $2; }} '`
do
kill -9 $pid
[ $? -eq 0 ] && echo "pid is killed" || echo "pid is not killed" >> /tmp/pid.log
done
sleep $stime
done
# end

# chmod +x unuse.ksh
# ./unuse.ksh &
# tail -f /tmp/pid.log
addendum1
New Member

Re: check the process

it is possible to add this new checking to the script ? thx