LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   How to kill pids for all sessions for a specific user except their current one? (http://www.linuxquestions.org/questions/programming-9/how-to-kill-pids-for-all-sessions-for-a-specific-user-except-their-current-one-839319/)

jasonws 10-20-2010 11:01 AM

How to kill pids for all sessions for a specific user except their current one?
 
Hey, I have several users on handhelds and they like to let their sessions time out. Their zombie processes then cause record locks.

A solution I've come up with calls for killing the pids for any prior sessions started by a given user. This procedure would be executed in the .bash_profile. Problem is, I have no idea how to do this. Thanks in advance for any help!

Jason

xandercage17 10-21-2010 04:46 AM

Delete My account

jasonws 10-22-2010 12:56 PM

Thanks, I appreciate your response. I'm familiar with kill and killall, w and ps, but not the code that would do what I need it to do. Maybe this will give you a better idea of what I'm trying to do. -Jason

[root@lynx dsi]# w |grep dsi
dsi pts/7 192.168.1.120 13:53 1:21m 0.03s 0.01s sshd: dsi [priv
dsi pts/4 192.168.1.120 13:53 0.00s 0.04s 0.01s sshd: dsi [priv

#Idle for pts/7 not 0. pts/7 must be the disconnected session.

[root@lynx dsi]# ps uU dsi |grep pts7
dsi 14341 0.0 0.0 7772 1420 ? S 13:53 0:00 sshd: dsi@pts/7
dsi 14342 0.0 0.0 4316 1440 pts/7 Ss 13:53 0:00 -bash

#Grab pids and kill them:
kill 14341 14342
sleep 10
kill -9 14341 14342

jasonws 10-22-2010 03:39 PM

I figured some things out and started a new thread here:
http://www.linuxquestions.org/questi...18#post4136218


All times are GMT -5. The time now is 07:24 PM.