Here is the script that kills old users processes

Jordan Erickson jerickson at logicalnetworking.net
Fri Nov 21 18:55:41 GMT 2008


There is always the faithful 'gnome-watchdog' package that I have 
running at 9 total LTSP sites, which seems to be working great and no 
ill effects after 3 months of use:

https://help.ubuntu.com/community/UbuntuLTSP/GnomeWatchdog


Cheers,
Jordan/Lns


Mattias Hemmingtsson wrote:
> Hi
>
> So a solved it or i find som code on the internet that helpt me :-)
>
> This collects the users from the ldap server and then kills 
> all that users processes.
> I run it every night to do some clean up
>
> #!/bin/bash
> #Script för att rensa upp i datorn varje dag
> #
> #Tar ut alla users till filen kill.log
> #rm kill.log
> #getent passwd >> kill.log
>
>
> # hämtar ut användarna och dödar deras processer
>
> awk -F: '{print $1,$3}' kill.log | while read user pid
> do
> (( pid > 1001 )) && skill -9 -u $user
> done
>
>
> But a also fint a script that kill sleeping processes byt i havet got it
> to work yeat but here it is.
>
> #!/bin/bash
>
> # max hours to be idle
> ( HOURS = 1 )
>
> # start number of user uid's
> ( UID = 500 )
>
> # file with users to exclude from killing (one user per line)
> excludefile=kill.log
>
> w -h | awk '!/root/{print $1,$5}' | while read user idle
> do
> # check if user is in excludefile
> [[ -n $( grep $user $excludefile ) ]] && continue
> # check for idle time
> [[ -n "$( echo $idle | grep -E 'm|s' )" ]] && continue
>
> # make hours of idle (throw everythig away after and incuding ':'
> # e.g. 2:35 will become 2
> idle=${idle%:*}
> # get uid from user
> uid=$( id -u $user )
>
> (( uid >= UID )) && (( idle >= HOURS )) &&  "pkill -9 -u $user"
> done
>
>
> // Mattias
>
>
>
>   


-- 
Jordan Erickson
Owner, Logical Networking Solutions
http://www.logicalnetworking.net
707-636-5678

Latest LNS Blogs - http://blogs.logicalnetworking.net

	Intel and HP team up to roll out Green PCs for the enterprise
	Mozilla Thunderbird Add-on "Signature Switch"
	Will "Windows 7" be another Mojave Experiment?




More information about the edubuntu-users mailing list