1834639 Members
2746 Online
110069 Solutions
New Discussion

Re: Terminate process

 
SOLVED
Go to solution
hangyu
Regular Advisor

Terminate process

We have a system user "oracle_usr" always run some process in the system , but sometimes , these processes will not stop automatically until we terminate the process , can suggest the method how to terminate the process that is run by "oracle_usr" and run over 10 minutes ? thx
5 REPLIES 5
Bill Hassell
Honored Contributor
Solution

Re: Terminate process

Just determine the process id and then issue the kill -15 command (NOT kill -9) to terminate the process.

It gets complicated if you want to do this automatically. There may be multiple processes, you wil have to verify you are killing the right process, etc,


Bill Hassell, sysadmin
Muthukumar_5
Honored Contributor

Re: Terminate process

You can do it as,

# ps -u oracle_usr | awk '!/PID/ { split($3,a,":");if (a[1]==10) { print $0 }}'

To kill them then,

# ps -u oracle_usr | awk '!/PID/ { split($3,a,":");if (a[1]==10) { print $1 }}' | xargs kill -9


hth.

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

Re: Terminate process

thx Muthukumar's help ,

may be my server have problem to run split , it pop the message "usage: kill [ -s signal | -p ] [ -a ] pid ..." , could suggest another simplier script ? thx

Bharat Katkar
Honored Contributor

Re: Terminate process

Ok ..
Another way of doing would like this:
1.

# w
-bash-2.05b# w
6:50am up 1 day, 23:53, 2 users, load average: 0.00, 0.00, 0.00
User tty login@ idle JCPU PCPU what
oracle_usr pts/ta 6:28am 23:59 -bash
root pts/tb 6:50am w

From the command above i know that oracle_usr is associated with terminal pts/ta
then do :

2.
# ps -t pts/ta
-bash-2.05b# ps -tpts/ta
PID TTY TIME COMMAND
6226 pts/ta 0:00 -bash
6225 pts/ta 0:00 telnetd
-bash-2.05b#
This will display all the process associated with that user. Say i have to kill bash then:
3.
# kill -9 6226

This should work.

Regards,
You need to know a lot to actually know how little you know
Amit Agarwal_1
Trusted Contributor

Re: Terminate process

Try

ps -u oracle_user | grep -v PID | awk '{ split($3, a, ":"); if(a[1] > 10) print $1;}' | xargs kill -9