?
Solved

Dead/orphan users

Posted on 2003-12-05
3
Medium Priority
?
519 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 100 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

Get proactive database performance tuning online

At Percona’s web store you can order full Percona Database Performance Audit in minutes. Find out the health of your database, and how to improve it. Pay online with a credit card. Improve your database performance now!

Question has a verified solution.

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

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses
Course of the Month12 days, 23 hours left to enroll

777 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