Index: [Article Count Order] [Thread]

Date:  Sat, 9 Sep 2006 13:28:41 +0200
From:  "F de Vries mediaPie" <info (at mark) mediapie.nl>
Subject:  [coba-e:06807] strange behaviour of spamd.fix posted before
To:  coba-e (at mark) bluequartz.org
Message-Id:  <20060909111730.M26423 (at mark) mediapie.nl>
In-Reply-To:  <1486c6440609081625l68dbfc23oe59d5fbf3f6b01fe (at mark) mail.gmail.com>
References:  <1486c6440609081125h192a0adas870b8630972b1676 (at mark) mail.gmail.com> <004a01c6d37d$33901090$6400a8c0 (at mark) YOUR4105E587B6> <1486c6440609081625l68dbfc23oe59d5fbf3f6b01fe (at mark) mail.gmail.com>
X-Mail-Count: 06807

In an earlier post a fix for the over quota (and suspended) users was 
written to avoid spamd to loop.
Strange anough it doesn't seem to kill every 3 minutes on my machines, 
sometimes it can last over an hour to be killed and it logs a lot of non-
exiting usernames such as 694, 692, 681 and 722...
Can anyone explain what's going on?
Thanx in advance,

   Ferris

This is a small portion of the log file:
2006-09-09 at 12:32 - Killed SPAMd process 1980 belonging to user 694 after 
00:17
2006-09-09 at 12:53 - Killed SPAMd process 2294 belonging to user srsams1 
after 00:44
2006-09-09 at 13:03 - Killed SPAMd process 2719 belonging to user 699 after 
00:39

There is a file /etc/cron.d/spamd.cron which contains:
*/1 * * * * root /usr/bin/spamd.fix


And this is the script usr/bin/spamd.fix

#!/bin/bash

LIMIT=`expr 3`
for PROID in `ps auxwf |grep "\_ spamd child"|grep -v root|awk '{print $2}'`
do
HOURS=`ps -fp $PROID | grep -v STIME | awk '{print $7}'|cut -d":" -f2`
MINS=`ps -fp $PROID | grep -v TIME | awk '{print $7}'|cut -d":" -f3`
USER=`ps -fp $PROID | grep -v TIME | awk '{print $1}'`
if [ "$HOURS" = "" ]
then
HOURS=`expr 0`
fi
if [ "$MINS" = "" ]
then
MINS=`expr 1`
fi
ELAPSED=`expr $HOURS \* 60`
ELAPSED=`expr $ELAPSED + $MINS`
if (test $ELAPSED -gt $LIMIT )
then
kill -9 $PROID
echo `date +'%Y-%m-%d at %H:%M'` - Killed SPAMd process $PROID belonging \
to user $USER after $HOURS:$MINS>> /home/spamdFix/log/spamdFix.log
fi
done