Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Dead/orphan users

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

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

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

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses

610 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