Re: detecting/killing eggdrops thru cron
Hi,
This is a little stupid perl script i wrote which killes processes from
users which are not logged on and which processes are not bound to a tty.
Additionally i use idled to kill idle users.
See if it fits and don't blame me for anything, it doesn't always work
like expected ;)
Regards,
Tommy
#!/usr/bin/perl
@online=`who|awk '{print \$1}'`;
@procs=`ps auxw |grep "\?" |egrep -v
"(root|daemon|grep|sshd|talkd)"|/usr/bin/awk '{print \$1" "\$2
" "\$11}'`;
foreach $line (@procs) {
($user,$pid,$what) = split(" ",$line);
$online = 0;
foreach $users (@online) {
if ( $user eq $users ) {
$online = 1;
}
}
if ( ! $online ) {
open(LOGJE,">>/var/log/killed.log") || die $!;
$time = scalar localtime;
print LOGJE "$time user $user pid $pid what $what\n";
close LOGJE;
`kill -9 $pid`;
}
}
On Wed, 12 Jan 2000, Sharon Ann wrote:
> hello All !
> i dont know shell scripting that well so i was wondering if someone can
> lend me a hand as to how to write a shell script that i can add in my cron
> w/c performs a "ps ax", tests the output to see whether there is a running
> process named "eggdrop" and if true, kills those processes ...
>
> TIA,
> Shawie =P~
>
>
> --
> To UNSUBSCRIBE, email to debian-isp-request@lists.debian.org
> with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
>
Reply to: