Solved

Dead/orphan users

Posted on 2003-12-05
3
514 Views
Last Modified: 2013-12-15
Is there an easy method to clean up dead or orphan users.  I have some users log on to a linux server, but don't exit cleanly.  I'm not an expert on linux, but the box is being used as a proxy, but there are users who log on to configure or restart certain services and don't exit cleanly.  I would like to know if there is some method available to clean up orphan user sessions.
pipporosso
0
Comment
Question by:pipporosso
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 40

Expert Comment

by:jlevie
ID: 9883825
If you look at the process list and find their shell you can kill that and "log them out".  As an example to kill the session for user jtest I'd do:

# ps -ef | grep jtest | grep -v grep
jtest     4100  4098  0 12:06 ?        00:00:00 /usr/sbin/sshd
jtest     4102  4100  0 12:06 pts/1    00:00:00 -bash
# kill -9 4102
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 9886075
See if you have the program pkill on your system. On my SuSE system it was installed with the ps package. pkill can be used to kill all processes that are owned by a specified user. This example kills all processes owned by the user "test"

pkill -9 -U test

You need to be root in order to kill processes owned by other users.
0
 
LVL 22

Accepted Solution

by:
pjedmond earned 25 total points
ID: 9898536
Just another tiny note  -If the STIME - start time is before today when you use 'ps -ef', then it will give the date that the process was started.

Processes that probably shouldn't be more than a day old include sshd, bash and probably a few others.

If you first identify the processes that should be killed, then you can run a cron daemon process to kill all of these processes off at say 23:59.....and all the processes that you want to delete that are over one day old.

An example:

ps -ef | grep Nov | grep bash


will list all bash processes older than today.

if you then | this through awk, and then /bin/sh, you can kill off all bash processes older than today:

ps -ef | grep Nov | grep bash | awk {'print "kill -9 " $2'} | /bin/sh


****Always run the command without the | /bin/sh  first to check that the commands printed to the screen are the commands that you actually want the shell to run.

Then repeat this process for all other processes that you want to kill that are over 1 day old:)

HTH:)




0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is the error message I got (CODE) Error caused by incompatible libmp3lame 3.98-2 with ffmpeg I've googled this error message and found out sometimes it attaches this note "can be treated with downgrade libmp3lame to version 3.97 or 3.98" …
Over the last ten+ years I have seen Linux configuration tools come and go. In the early days there was the tried-and-true, all-powerful linuxconf that many thought would remain the one and only Linux configuration tool until the end of times. Well,…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question