[K12OSN] Kill User processes on log-off

Jim Kronebusch jim at winonacotter.org
Tue Feb 22 21:27:32 UTC 2005


I have seen some stuff on this list over the last few days regarding
cleaning out /tmp and killing user processes and such.  The following is
a snip from a post on the ltsp mailing list that looks like a good
solution.  Instead of killing /tmp and user process with a scheduled
cron, it kills processes and /tmp/files by user on user logoff.  First
is a description of the original post, then anothers users suggestion
for a fix.  Would it make sense to incorporate something like this as a
built in tool to prevent buildup of defunct user stuff which seems to
lead to crashes?

Original Post
--------------------------------------------------
> I'm looking for a simple way to kill off any
> leftover, orphan, or
> defunct processes that remain alive after a user is disconnected from
> the server.  
> 
> We are running Fedora Core 3 and GDM as the display
> manager.
> 
> I have read a little about using the postsession
> script to kill these
> processes off, but haven't found a really clear
> instruction on how to
> accomplish this.
--------------------------------------------------

Posted Solution
--------------------------------------------------
I've had good results using the debian "slay" command
called by /etc/X11/gdm/PostSession/Default.

You can download slay as a .tar.gz
http://ftp.port80.se/debian/pool/main/s/slay/

Note that I also remove all /tmp/ files owned by the
user in a fairly sloppy manner. (I depend on unix
permissions to protect files not owned by the user.) 

The important part of PostSession/Default is:
----------
if [ "$USER" != "root" ] ; then
  rm -rf /tmp/*
  slay $USER
fi
----------
My entire PostSession/Default is:

----------
#!/bin/sh

PATH="/usr/bin/X11:/usr/X11R6/bin:/opt/X11R6/bin:$PATH:/bin:/usr/bin"

SESSREG=`which sessreg 2>/dev/null`
if [ "x$SESSREG" != "x" ] ; then
        "$SESSREG" -d -w /var/log/wtmp -u
/var/run/utmp -x "$X_SERVERS" -h "$REMOTE_HOST" -l
"$DISPLAY" "$USER"
fi

if [ "$USER" != "root" ] ; then
  rm -rf /tmp/*
  slay $USER
fi



exit 0
----------


-- 
This message has been scanned for viruses and
dangerous content by the Cotter Technology 
Department, and is believed to be clean.




More information about the K12OSN mailing list