Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-20-2010, 11:01 AM   #1
LQ Newbie
Registered: Oct 2010
Location: Vermont, USA
Posts: 15

Rep: Reputation: 0
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!

Old 10-21-2010, 04:46 AM   #2
Registered: Sep 2009
Posts: 125

Rep: Reputation: Disabled
Delete My account

Last edited by xandercage17; 04-22-2012 at 03:00 PM. Reason: Delete My account
Old 10-22-2010, 12:56 PM   #3
LQ Newbie
Registered: Oct 2010
Location: Vermont, USA
Posts: 15

Original Poster
Rep: Reputation: 0
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 13:53 1:21m 0.03s 0.01s sshd: dsi [priv
dsi pts/4 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

Last edited by jasonws; 10-22-2010 at 01:00 PM.
Old 10-22-2010, 03:39 PM   #4
LQ Newbie
Registered: Oct 2010
Location: Vermont, USA
Posts: 15

Original Poster
Rep: Reputation: 0
I figured some things out and started a new thread here:


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill specific vnc user from joint session jo4 Linux - Newbie 1 05-07-2011 03:08 AM
Number of current sessions for user neel_learning_linux Linux - Newbie 5 05-13-2009 03:14 PM
Can you kill off other sessions (gui and terminal) Thaidog Linux - General 2 03-30-2008 03:51 PM
Log Out a Specific User (KILL) carlosinfl Linux - General 8 08-29-2007 10:53 AM
kill opened sessions aizkorri Linux - Newbie 3 09-25-2003 09:08 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:45 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration