Operating System - Linux
1751955 Members
4921 Online
108783 Solutions
New Discussion юеВ

RSH: Find & Kill the Process by automation

 
Mugilvannan
Valued Contributor

RSH: Find & Kill the Process by automation

Here the thing I'm doing by manually once my automation has failed :

Process identify-> C:\>rsh ps -ef | grep agent

Output -> SYSTEM 2576 2180 0 10:52:40 CONIN$ 0:00 C:\tmp\exec\MGR107\mgragent.exe

Killing Process-> C:\>rsh kill -9 2576

I'm doing this manual process before starting the new automation run.

I would like to automate this process like find the process id and then kill it. Can someone help me on this?

Thanks,
Mugil
If U need a helping hand, U will find one at the end of your arm
4 REPLIES 4
RAC_1
Honored Contributor

Re: RSH: Find & Kill the Process by automation

grep is not a good idea.

ps -ef | grep -i mugil

will give you as follows. (assuming that there are process mugil mugilevyx, mugilggh, hjmugillp)

You can do it as follows.

rsh "host" 'UNIX95= ps -C"process_name" -p pid=|xargs kill'

Make sure that you are killing a right apps/process that you want to kill.
There is no substitute to HARDWORK
Arunvijai_4
Honored Contributor

Re: RSH: Find & Kill the Process by automation

Its hard to kill a process everytime by its PID since it is not a constant value. You may need to write a script such a way that, it should grep by process name and get PID, then kill it.

May be this link can help you,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=838620

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Mugilvannan
Valued Contributor

Re: RSH: Find & Kill the Process by automation

Thank you both of U. But still I'm getting,

C:\>rsh 'UNIX95= ps -C emagent -p pid=|xargs kill'

Winsock RSHD/NT: Error 2 executing 'UNIX95= ps -C emagent -p pid='
The system cannot find the file specified.

I forget to mention that I'm want to kill the process on Windows host.

And I tried this too,

C:\>rsh ps -ef | grep agent | awk '{ print $2 ; }
' | xargs kill -9
kill: 780: no such process


C:\>rsh ps -ef | grep agent | grep -v grep | awk '{ print $2 ; }
' | xargs kill -9
kill: 780: no such process

Am I missing any more?
If U need a helping hand, U will find one at the end of your arm
Mugilvannan
Valued Contributor

Re: RSH: Find & Kill the Process by automation

I'm closing this thread since we found a way like this:

1) create a .sh file in remote machine containing ps -u ps -ef | grep -v 'grep'
| grep agent | awk '{ print $2; }' | xargs kill -9

2) create a .bat file in same host which is calling the above .sh file

3) run rsh command calling the .bat file

Thanks,
Mugil
If U need a helping hand, U will find one at the end of your arm