Solved Script for how to kill one of the two same processes

September 7, 2012 at 06:13:56
Specs: Unix
I find that every few hours i have two instances of sshd running in the same time. I am trying to run a script that will kill only one of them. So far I got to this point:

If I run the below command the output can be 2 04 3 lines:
#ps -aef | grep ‘sshd:’ | grep -v grep | awk '{print $2}'
8786
8792

What command can I add to the first one to kill only one of the running instances?

Thanks!

Cos


See More: Script for how to kill one of the two same processes

Report •

#1
September 7, 2012 at 17:32:04
✔ Best Answer
How about quitting after printing the first line:

# UNTESTED
ps -aef|grep 'sshd:'|grep -v grep|awk ' { print $2; exit } '


Report •

#2
September 14, 2012 at 09:58:05
It worked. Thanks for the idea

Report •
Related Solutions


Ask Question