[K12OSN] Kill User processes on log-off

Robert Arkiletian robark at telus.net
Thu Feb 24 03:52:33 UTC 2005


Andy Rabagliati wrote:

>On Wed, 23 Feb 2005, Jim Christiansen wrote:
>
>  
>
>>In my 3.x install, all proccesses for a user were killed at both ends.  A 
>>script ran at logon that killed all processes and also at logoff.  I wish I 
>>could find it.  I don't seem to have a need for it this year.
>>    
>>
>
>I squirrelled this one away - is it what you are looking for ?
>
>It runs at login time.
>
>Cheers,      Andy!
>  
>


How do you learn to squirrel code like this? Do I just start reading any 
bash script book? Also how does one run scripts at login or logoff?

Script-Wizard-Wannabe
Robert Arkiletian

>
>#!/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
>
>_______________________________________________
>K12OSN mailing list
>K12OSN at redhat.com
>https://www.redhat.com/mailman/listinfo/k12osn
>For more info see <http://www.k12os.org>
>
>  
>


-- 


Robert Arkiletian
C++ GUI tutorial http://fltk.org/links.php?V19




More information about the K12OSN mailing list