LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Need client processes on a particular IP address (https://www.linuxquestions.org/questions/linux-server-73/need-client-processes-on-a-particular-ip-address-4175455829/)

jjfahey 03-27-2013 03:00 PM

Need client processes on a particular IP address
 
I need to determine the IP address for one or several processes, for an automated kill-script. Back in "the day" I would use their "tty" to do this, but the client processes that I am dealing with don't supply their own ttys - So I need their IP addys - I've looked a bit at the ps man pages and the like, and haven't seen anything. I know that stuff is out there somewhere, since it shows up in w and some who options, but where? Thanks in advance!

kbp 03-27-2013 05:19 PM

Does this help?

Code:

# target specific processes
pkill -f <glob>

# target all processes owned by a specific user
killall -u <user>


Habitual 03-27-2013 06:47 PM

or possibly a combination of the two?
Code:

pkill -KILL -u <user>
Warning: Do NOT use this on root!

jjfahey 03-27-2013 07:12 PM

Unfortunately, no ... But thanks much for the responses - I am killing processes on workstations (PCs and the like) which I have determined to be idle (by database means). If I determine that all db processes on a particular IP addy are idle, then I need to kill all of them. My original script looped through all the processes on the tty (with ps -t </dev/tty##> or whatever), and killed 'em all, but now there are appears to be no simple cmd to replace <tty> with <IP>. And, of course, our users insist on logging in more than one place, so I can't just kill by logname. Ugh. I have found some stuff in /proc/<PID>/environ which may be workable, but it would've been a whole lot simpler with a "ps minus" option! Again, thanks for your input ... Cheers!

kbp 03-27-2013 08:12 PM

That seems to be a strange approach .. any reason you can't set idle session timeouts on the database?

jjfahey 03-28-2013 02:55 PM

A couple of issues there. First, our menu is also a database session, and it is almost always idle even if its children are busy, so we can't kill it just because it is idle. Of more import is the fact that we only want to "idleout" sessions if and only if ALL sessions for that IP are idle, and then we need to kill them all, including the menu session(s). Hence my need to drag IPs and PIDs "together." No worries though, I've now bolted together something using /proc/<PID>/environ which is now working for me ... I was just hoping for a simple ps <minus> option! Thanks for your input though ... Cheers! John


All times are GMT -5. The time now is 01:21 AM.