script for cleaning up zombie user processes at the end of the day?

john lists.john at gmail.com
Fri Jan 19 18:40:54 GMT 2007


Thanks to everybody for elucidating this script. I really appreciate folks
taking the time!

John

On 1/19/07, Clay Berlo <clay.berlo at dsbn.edu.on.ca> wrote:
>
>  Good analysis!  Your rundown of what the script does is fairly accurate.
>
> The $3 bit was a little confusing for me, too, until I played around with
> a similar script.  Basically, the getent lists the users in a
> user:passwordtoekn:uid kind of format, so when passed to awk with the -F:
> (setting : as a field delimiter), the 3rd field is the UID.  After you have
> the UIDs you're working with, it cycles through to see who's logged in with
> a current session (thus the gnome-panel stuff) and kills any bonobo process
> not attached to an active session.  (I was having a problem with bonobo
> processes not being killed off.)
>
> slay might work, but I imagine you'd have to follow a similar logic to
> make sure you're not killing off any root processes or active users.
>
> On Thu, 2007-18-01 at 15:14 -0800, john wrote:
>
> Thanks Clay. I appreciate the script. I am going to try this out. But
> before I do, I hope you can help me to understand what is going on a little
> better? Anyone who feels like chiming in would be quite welcome.
>
>
> 1) basically I think this script is looping through the password db by
> calling the program 'getent' and piping the results to awk.
>
> 2) Awk is applying a separator : and then something magical happens (what
> is $3?) Somehow uids are getting assigned to this variable?
>
> 3 Then somehow (related to $3) we look for uids above 999 and pass them to
> $1 which will print them to standard output (i.e the tty from which this
> script is executed, if executed by hand). Is there more going on here?
>
> 4) then the script echos the result of the variable $user and runs 'pgrep
> -u' against the expanded variable $user for any gnome-panel and bobono
> processes owned by that user
>
> 5) the program loops until done.
>
> Sorry, I just like to understand what I am doing before I do it. Will
> killing zombie type gnome-panel and bonobo stuff, clean up leftover
> processes like firefox, games etc?
>
> TIA!
>
> John
>
>  On 1/18/07, *Clay Berlo* <clay.berlo at dsbn.edu.on.ca> wrote:
>
>  Funny, I just ran into the same kind of problem myself not so long ago.
> Talked to they guys on IRC and was given the following:
>
> for user in $(getent passwd | awk -F: '$3 > 999 {print $1}'); do echo
> $user; pgrep -u ${user} gnome-panel || pkill -u ${user} bonobo; done
>
> Now, my system is running the "usual" gnome stuff, so this works for
> killing off processes from anyone not logged in.  If you're using KDE or
> XFCE, you'll have to scan for something other thant gnome-panel.
>
> Oliver Grawert has suggested this should go into the ldm script somehow.
> As I'm not familiar with how to play around with that file, I just stuck in
> a cron job to run hourly.
>
>
>
> On Wed, 2007-17-01 at 14:30 -0800, john wrote:
>
> Hello all,
>
> I'm running ltsp 4.2 on Ubuntu LTS 6.06 using win2k3 AD for auth. I find
> that at the end of the day I have a lot of leftover student user processes
> running, and I'd like to have a little script that kills them all after
> school. Does anyone have something ready-made or do I need to brew one
> myself?
>
> TIA!
>
> John
>
>     --
> Clay Berlo <clay.berlo at dsbn.edu.on.ca>
> DSBN Technical Services
>
>
>   --
> Clay Berlo <clay.berlo at dsbn.edu.on.ca>
> DSBN Technical Services
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: https://lists.ubuntu.com/archives/edubuntu-users/attachments/20070119/cc47bbd6/attachment.htm 


More information about the edubuntu-users mailing list