[K12OSN] Kill User processes on log-off

Jim Christiansen christiansen_j at hotmail.com
Thu Feb 24 00:46:56 UTC 2005


Hey!  This may be it!  Are you using it in your intallation?  I wish I had 
my old one...  I actually do come to think of it.   I've got the whole drive 
mounted on the current running system, but where to find it is the 
question?!!  I guess I'ld start looking at what is called at IceWm logoff 
because it was- on my system, the same script at logon and logoff...

Ok, Ok!!  I'll check tomorrow.  My brain is mush.

Jim

<snip>
I squirrelled this one away - is it what you are looking for ?

It runs at login time.

Cheers,      Andy!


#!/bin/sh
#Lumen Software
#www.lumensoftware.com
#collected from various irc chats, and mailing lists

## clean up files left in /tmp ##

# evolution
for evoTmpDir in /tmp/evolution-$EUID-*
do
  [ -d $evoTmpDir ] && rm -Rf $evoTmpDir
done

# orbit & KDE temp directories
[ -d /tmp/orbit-$USER ] && rm -Rf /tmp/orbit-$USER
[ -d /tmp/ksocket-$USER ] && rm -Rf /tmp/ksocket-$USER
[ -d /tmp/kde-$USER ] && rm -Rf /tmp/kde-$USER
[ -d /tmp/mcop-$USER ] && rm -Rf /tmp/mcop-$USER

# remove any scrollkeeper tempfiles
for TempFile in /tmp/scrollkeeper-tempfile*
do
[ `stat -c %u $TempFile` -eq $EUID ] && rm -Rf $TempFile
done

## session clean up ##

# no touch root, many services will die
[ $USER = 'root' ] && exit 0

# kill oaf daemon
oafdpids=`ps -u $USER | grep oafd | cut -c1-5`
[ -z $oafdpids ] || kill -1 $oafdpids

# clean up unexpected
LeftoverPids=`ps ho pid -u $USER`
if [ ! -z "$LeftoverPids" ]
then
    logger -it GDM $USER "WARNING processes left behind"
    ps -aef|grep ^$USER | logger -it GDM
    logger -it GDM "TERM signals to $LeftoverPids"
    kill -15 $LeftoverPids | logger -it GDM
    sleep 1
    LeftoverPids=`ps -aef | grep ^$USER | cut -c10-15 `
    if [ ! -z "$LeftoverPids" ]
    then
        logger -it GDM "KILL signals to $LeftoverPids"
        kill -9 $LeftoverPids | logger -it GDM
        sleep 1
        LeftoverPids=`ps -aef | grep ^$USER | cut -c10-15 `
        if [ ! -z "$LeftoverPids" ]
        then
            logger -it GDM "FAIL kill $LeftoverPids"
            ps -aef | grep $LeftoverPids | logger -it GDM
        fi
    fi
fi
</snip>





More information about the K12OSN mailing list