is there a way to find the process id of a process because i have same process invoked several times.
when i need to kill them, i get confused with the id.
Thanks,
sskb

is there a way to find the process id of a process because i have same process invoked several times.
when i need to kill them, i get confused with the id.
Thanks,
sskb

best way if you can do ps -aux im sure the process name that you are running. If you can try ps --username for the current process that you execute, by this way you have a idea on which process can be killed, rather then confused of all the systems process. One more suggestion ps -eo "%p" actually it will lists out the normal default output and easy for you to kill (works on AIX havent try on any other OS's) Give a try post back if this doesnt help..
hi killerserv,
thanks for ther response, but i think i need to explain more..
well, I am using a HP Unix system.
and I generally use
ps -u username
and try that..
but when i have a number of same processes and i want to kill only one of them.. such as
i have 4 netscapes running out of which i need to kill one.. i do not know which id corresponds to which process..
like......
$ps -u username | grep netscape
3598 pts/1 0:00 netscape
4561 ? 0:00 netscape
3596 pts/1 4:07 netscape
4560 ? 1:31 netscape
3794 ? 3:34 netscape
3795 ? 0:00 netscape
now is there a way to identify that from the netsacpe itself?
thanks,
sskb
Well, you could use ps -ef, which shows the parent process id as well, and check to see who (or what) started it.
Hi LivinFree,
I tried
ps -ef |grep netscape
sskb 2430 2429 0 22:55:51 ? 1:35 /usr/local/netscape/netscape
sskb 2508 2507 0 23:14:39 ? 0:09 /usr/local/netscape/netscape
but i do not get anything like the window id..(if there is one).. so that i can know what i need.
well, is there any utility which can give the status of a window along with process id..
i think this would be a great help.
Thanks,
sskb
In your example 'ps -ef | grep netscape' resulted in:
sskb 2430 2429 0 22:55:51 ? 1:35 /usr/local/netscape/netscape
sskb 2508 2507 0 23:14:39 ? 0:09 /usr/local/netscape/netscape
In the first line, the PID 2430 represents the PID of the running task 'netscape'. Now if you do a ps on the Parent PID (PPID):
ps -ef | grep 2429
you'll find the owner of the task netscape. -mk
hi Mike,
I get your point..
but I need to correlate between the process id and the process window.
let me know if that isn't making sense,
Regards,
sskb
OK. Let's go at this from another direction.
If you type:
who am i
you wil get a response like:
root pts/0 Apr 10 03:53 (:0.0)
pts0 is the terminal window I typed the 'who am i' command. Now if I type:
who -uH
I get:
NAME LINE TIME IDLE PID COMMENT
root pts/0 Apr 10 03:53 . 1177 (:0.0)
root pts/1 Apr 10 03:53 00:01 1176 (:0.0)
All users logged into your system would be listed under the NAME column. You'll notice the PID column, This is the pid of the shells running in the two windows I have open, as root. OK, now lets run:
ps -ef | grep 1177
on the PID of shell running on /dev/pts/0. I get:
UID PID PPID C STIME TTY TIME CMD
root 1177 1171 0 03:53 pts/0 00:00:00 bash
root 1252 1177 0 03:55 pts/0 00:00:00 ps -ef
root 1253 1177 0 03:55 pts/0 00:00:00 grep 1177
You'll see that 1177 is the PID of bash and the PPID of both 'ps' and 'grep'. You'll also see that in the TTY column, it also references the TTY the commands where run in.
Basically, with the use of 'ps -ef' and 'who -uH', you can determine any command run by any user in any window or terminal. I hope this helps. -mk
thanks mk for the detailed info.. but well, i think we are pulling out somewhere else!
let me explain once again.
i have invoked some 'netscape' (not a single one.. more) for example. I did not use any terminal window to invoke this but a desktop action. fine i know the process id.
when i need to kill that .. i can use
ps -u $LOGNAME|grep netscape
i get like this
ps -u $LOGNAME | grep netscape
8018 ? 0:00 netscape
8090 ? 0:00 netscape
8089 ? 0:17 netscape
8017 ? 0:13 netscape
in these process ids.. i need to kill only one netscape.. I can identify the window.. but not the process id corresponding to that.
adding more info...
i can do this with X-Kill... i can invoke "xkill" and click that window and it dies.. but when my system hangs because of that particular 'netscape'
i can not access "xkill", so i do a remote login and i want to kill only that process..
in this case, is there a solution?
Thanks,
sskb