1847201 Members
3381 Online
110263 Solutions
New Discussion

Re: Unuse process

 
addendum
Advisor

Unuse process

I found that in my system , there are some strange process , it will make the system crash so I would like to control the system no such process is running ,
I found that if the system process that its process name is "ora" AND its ppid is not "2" , then it will crash the system, can suggest how to make sure the system no such kind of process is running ? thx
17 REPLIES 17
Arunvijai_4
Honored Contributor

Re: Unuse process

Check your RC scripts, they are located in /etc/rc.config.d/. It seems like it is oracle process. Are you sure you dont want that to run ?

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
addendum
Advisor

Re: Unuse process

thx reply ,

it is not related to "oracle" , it is "ora" that the application we use .
can suggest the script / way to do that ?

thx
Arunvijai_4
Honored Contributor

Re: Unuse process

OK, Have you looked into your RC scripts to stop loading from startup ?

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
addendum
Advisor

Re: Unuse process

the strange process is generate from our application , I would prefer to use the script to fix it because it happen in my other unix base system . thx in advance.
RAC_1
Honored Contributor

Re: Unuse process

First, what exactly is this process?? What it does?? Is it running or hung process??

glance, select process, wait state if it is a hung process. If it is hung process, you can not kill it and reboot remains the only option.
There is no substitute to HARDWORK
Arunvijai_4
Honored Contributor

Re: Unuse process

OK, then you can kill it at the startup. Edit your /etc/profile or /.profile and add the following lines,

kill -9 `ps -ae |grep -i "ora"||awk '{ print $1}'`

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
addendum
Advisor

Re: Unuse process

thx RAC,

it is running process , the process is for system checking ,

thx Arunvijai,

you script seems not check the ppid , I use 'ps -ef' can find the ppid .

thx
Vibhor Kumar Agarwal
Esteemed Contributor

Re: Unuse process

If it starts periodically you can add the above script in cron.
Vibhor Kumar Agarwal
RAC_1
Honored Contributor

Re: Unuse process

Never us signal 9 to kill process. That is a bad sysadmin practise. It just kills the process and does not do any cleanup with respect to memory and other resouces that process is using. I ususally do as follows.

kill -15 "pid"
kill -1 "pid"
kill -2 "pid"
kill -3 "pid"
kill -11 "pid"

Last resort
kill -9 "pid"

you can kill you process as follows.

UNIX95= ps -C"process_name" -o pid= | xargs kill
There is no substitute to HARDWORK
Muthukumar_5
Honored Contributor

Re: Unuse process

You can get those process information as,

ps -ef | grep -i 'ora' | awk '!/COMMAND/ { if ( $2 != "2" ) { print; } }'

Is there anything in /etc/rc.log or syslog on regaring problem with this application startup.

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

Re: Unuse process

thx all help ,

in Muthukumar's script
ps -ef | grep -i 'ora' | awk '!/COMMAND/ { if ( $2 != "2" ) { print; } }'

could suggest if I want to kill the process and log what process that it has kill , what can I do ? thx

and I am not too understand what is the function of rc script , is it useful for controlling such process ? thx
Muthukumar_5
Honored Contributor

Re: Unuse process

Script of ps -ef | grep -i 'ora' | awk '!/COMMAND/ { if ( $3 != "2" ) { print $2; }} ' will execute ps -ef command and then,

=> grep out ora with case-insensitive
=> It will remove the first line of ps -ef ouput
=> It will check for ppid not equal to 2

To track all process and killed information then,

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

cat /tmp/pid.log will give information.

hth.

Easy to suggest when don't know about the problem!
addendum
Advisor

Re: Unuse process

thx Muthukumar ,

what is the use of the below string ? thx

!/COMMAND/
addendum
Advisor

Re: Unuse process

thx Muthukumar again ,

how to make your script to run 10 times per every 1 minute ? thx in advance.
Muthukumar_5
Honored Contributor

Re: Unuse process

Use of !/COMMAND/ is,

# ps -ef
UID PID PPID C STIME TTY TIME COMMAND
root 0 0 0 Sep 20 ? 0:16 swapper

to remove first line of UID PID .. COMMAND from usage with scripting.

hth.
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Unuse process

>>how to make your script to run 10 times per every 1 minute
>>

#!/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

# Use ctr + d to stop it. Or you can use crontab to schedule it accordingly. Change stime variable to suite your requirement.


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

Re: Unuse process

thx Muthukumar ,

your method is excellent , I want to have one more question , if run this script , it seems try to kill the pid that in the script running grep , like the below example , it seems try to kill the process 32612 , can suggest how to prevent the system kill it ? thx


root 758 1 0 Jul23 ? 00:02:26 ora
root 768 1 0 Jul23 ? 00:00:00 ora
root 32612 22295 0 21:45 pts/0 00:00:00 grep ora