[K12OSN] cron to kill users or group?
Mike Ely
mely at rogueriver.k12.or.us
Fri Mar 24 19:49:18 UTC 2006
William Fragakis wrote:
> Hi,
> An issue we frequently have is that repeated instances of programs
> orphaned eventually bring down a server. It arises from a couple of
> situations: 1) a client crashing then gets rebooted or 2) multiple
> instances of a program are opened (eg TuxPaint) instead of using an
> already open program. The second type is the more difficult because we
> have a lot of young kids and in a special situation, special needs kids
> - so we want something transparent to them. We'd rather sort the problem
> out on the server side than "educate" them since exploring the computer
> is so much fun for them. I've found scripts that kill a certain user,
> I've found scripts that kill certain processes but what I'd like is
> something that ends all the regular user processes, say, at midnight and
> let's the clients "refresh" without having to reboot or log back in. I
> don't want to restart the server every night - well, because it's a
> server and we love our uptime.
>
> Is anyone using anything to end the processes for a certain group, say,
> as a cron job?
>
> TIAA
> William Fragakis
> Morris Brandon Elementary
>
Yes, there is - the program is called "slay" and it's actually a pretty
simple shell script. With Debian, just apt-get install slay, and I'm
guessing redhat will have it in a yum repository.
As far as getting it into cron, it's just a matter of slaying by
username with whatever signal you want to pass the processes:
usage: slay [-signal] name [name...]
Kills all processes belonging to any of the given names.
Use -clean as a signal name to kill with TERM first and then
with KILL.
I once wrote a program called "slayer" to keep generic student accounts
off my LTSP lab (because Firefox and OpenOffice don't like multiple
instances with the same user account) - it went something like this:
#!/bin/sh
while true; do
sleep 10s
slay <generic account usernames>
done
Heavy metal references aside, I'm sure you could get something similar
into your crontab without much difficulty.
Cheers,
Mike
More information about the K12OSN
mailing list