LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 11-30-2005, 08:35 PM   #1
goemon
LQ Newbie
 
Registered: Nov 2005
Posts: 17

Rep: Reputation: 0
How to kill an idle user via the command line?


I'm really sorry to be asking what is surely an easy question, but 1) I have googled for hours and 2) I have searched through old forum posts and 3) I have pulled out a shell programming book and can't figure out how to do this. All I need to do is kill idle users that for some reason persist even though I'm no longer there.

If I run "who," for example, I get the following:

frog pts/1 Nov 30 15:38
turtle pts/2 Nov 30 16:10
turtle pts/3 Nov 30 16:13
turtle pts/4 Nov 30 17:09
frog pts/0 Nov 30 15:38
turtle pts/5 Nov 30 20:02
turtle pts/6 Nov 30 20:27
turtle pts/8 Nov 28 10:09 (remotelogin.zoolab)

"turtle" hasn't been at the zoolab for a day and a half, so why is he still showing up? AND, when I then use "who --all" to get a PID and try (even as root!) to kill it (kill -9 PID#), I get the message "No such process."

What other ways can I kill this idle instance of "turtle." Sometimes there are 30 or more!

Lastly, I know about "idled" but don't really know enough about changing the configuration files to try to get it to do that automatically. I just want to have a simple command line that I can type and kill these idle users whenever I want to.

Thanks very much for any and all help.
 
Old 11-30-2005, 09:05 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Try the "who -q" to determine the users currently logged in.

Also, determine the current processes by user with: ps -u turtle

Then if there are any process by this user, you can kill them by their displayed PID number.
 
Old 11-30-2005, 09:35 PM   #3
goemon
LQ Newbie
 
Registered: Nov 2005
Posts: 17

Original Poster
Rep: Reputation: 0
Can I narrow it down?

Okay, that's a start, but the "who --all" seems to give me more info AND the PIDs. If I do "who -q" it just lists things like "frog turtle turtle turtle frog frog turtle turtle turtle turtle frog" and if I do the "ps -u turtle" then it gives me ALL the PIDs of ALL the turtles. What I need is a way to quickly kill the "turtle" on "pts/8" but NOT the turtle(s) that's logged in and active. I don't want to kill everything with turtle.

If I do "who --all" I get something like this:
LOGIN tty5 Nov 22 15:27 21925 id=5
LOGIN tty6 Nov 19 22:07 1235 id=6
... (more here)
turtle + pts/8 Nov 28 10:09 old 2882 (remotelogin.zoolab)
pts/9 Nov 29 20:59 14807 id=/9 term=0 exit=0
pts/10 Nov 30 15:16 30062 id=/10 term=0 exit=0
...(more here too)

It looks like 2882 is the PID for turtle on + pts/8. But if I try to "kill -9 2882" I get a "Cannot kill 2882...no such process" error.

So what is the syntax to kill JUST that one instance of turtle, the idle one on pts/8? Any ideas?
 
Old 12-01-2005, 05:46 AM   #4
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655Reputation: 655
Does "ps -u turtle" show the processes. I'm wondering if you are looking at processes that were present in the past.
Something else to check is to see if they have cron jobs running.
 
Old 12-01-2005, 08:06 AM   #5
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 53
Then just slay the turtle
Code:
slay turtle
I dunno if its standard , maybe you have to install it.
 
Old 12-01-2005, 02:23 PM   #6
goemon
LQ Newbie
 
Registered: Nov 2005
Posts: 17

Original Poster
Rep: Reputation: 0
cron jobs?

According to the "who" manpage, "who --all" displays processes.

How do I find the cron jobs and what will this accomplish?

("slay" isn't on my system, by the way. But even if it was, wouldn't that kill ALL instances of turtle? Not just the one on pts/8?)

Thanks...I'm sorry this is still unsolved...
 
Old 12-01-2005, 06:45 PM   #7
sundialsvcs
Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,452

Rep: Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172Reputation: 1172
It's a bit obscure, but have a look at man wtmp. The "list of who's logged-on" can be fooled.

Use ps -uturtle to see if any processes, particularly bash, still exist which belong to this user-id. If so, you can kill the bash-processes (as root) and this should cause the user to be logged-off. (All of the processes spawned by the session will be direct or indirect descendents of his shell, and should die when it does.)
 
Old 12-01-2005, 07:01 PM   #8
goemon
LQ Newbie
 
Registered: Nov 2005
Posts: 17

Original Poster
Rep: Reputation: 0
Okay...

Thank you, Sundialsvcs, for that info. Interesting. Perhaps this pts/8 "turtle" isn't even there? It's just a phantom that "who" is reporting? That would explain why I'm getting the "can't kill the process, it doesn't exist" error.

Last question for you:

If I have 2 users, frog and turtle, and I _don't_ want to kill all instances of turtle but just a specific one (such as the one on pts/8, not tty3 or pts/1 or pts/2) is there a way to list JUST the bash shells that belong to pts/8? I'm worried that if I kill the wrong bash shell I'll kill the current (non-idle!) turtle instead of the old phantom one.

Lastly, can I clean up the "who" reporting? It doesn't look like I should mess with "wtmp" at all...but if "who" isn't reporting accurate info how do I fix that?
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kill a user off line phiberoptik Slackware 10 11-24-2004 08:10 PM
kill idle user ust Linux - Software 3 08-31-2004 03:19 PM
who idle user how to kill saavik Linux - Networking 1 03-04-2004 11:12 AM
kill program command line demmylls Linux - General 7 02-09-2004 09:55 PM
one-line kill command using process name julianop Linux - Newbie 6 12-23-2003 12:33 AM


All times are GMT -5. The time now is 10:11 PM.

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