Edubuntu LTSP cleanup of persistent stale processes
Jordan Erickson
jerickson at logicalnetworking.net
Wed Apr 22 19:51:47 BST 2009
Hi Andy,
Take a look at
https://help.ubuntu.com/community/UbuntuLTSP/GnomeWatchdog - it seems to
accomplish this as well.
Cheers,
Jordan/Lns
Andy Figueroa wrote:
> I am a happy, but sometimes frustrated, system administrator of an
> Edubuntu LTSP installation in a private school's very busy computer lab.
> I'm running a fully up-to-date hardy 8.04 LTS setup.
>
> Searching Google for 'ubuntu ltsp cleanup processe' it doesn't look like
> there is going to be a systemic solution to this in the immediate
> future, so I wrote a bash script (series of scripts, really) to clean up
> these many detached processes, without affecting users that are
> currently logged in or killing any system processes.
>
> The main script: killstale.scr can be run manually by root or via sudo.
> I run it hourly during school days via root's crontab. It looks like
> this:
>
> #!/bin/sh
> #
> # This series of bash commands will kill all processes owned by
> # ordinary users who are not currently logged in.
> #
> # Make a list of all processes with an owner
> ps axu | cut --delimiter=" " -f 1 | sort -u > killstale.list
> # Make a fresh list of all ordinary users with directory in /home
> ls --color=never /home > killstale.home
> # Reduce list to processes owned by those ordinary users
> fgrep -f killstale.list killstale.home > killstale.users
> # Find out who is currently logged in
> w -h | cut --delimiter=" " -f1 > killstale.w
> # Create new list minus users currently logged in
> fgrep -v -f killstale.w killstale.users > killstale.xusers
> # Identify user processes with user number
> grep 1... killstale.list > killstale.num
> # Find out who those user numbers belong to
> fgrep -f killstale.num /etc/passwd | cut --delimiter=: -f1 > killstale.name
> # Add those processes to the list
> cat killstale.xusers killstale.name > killstale.semi
> # Eliminate duplicate user names
> sort -u killstale.semi > killstale.final
> # Kill all processes owned by those not-logged in ordinary users
> /root/killstale1.scr
>
> killstale1.scr looks like this:
> #!/bin/sh
> /root/killstale2.scr < /root/killstale.final
>
> and killstale2.scr like this:
> #!/bin/sh
> read users
> while [ -n "${users}" ] ; do
> killall -u ${users}
> read users
> done
>
> I'm definitely interested in your thoughts or better ideas.
>
> Andy Figueroa
>
>
>
--
Jordan Erickson
Owner, Logical Networking Solutions
http://www.logicalnetworking.net
707-636-5678
Latest LNS Blogs - http://blog.logicalnetworking.net
Leaving computers on overnight = $2.8 billion a year
Starbucks Ditches T-Mobile, Will Offer AT+T WiFi
Google Earth Uncovers Brit Nuclear Sub Base, Missile Facility
More information about the edubuntu-users
mailing list