Hi
i wrote s simple bash script that will check php-mail.log of users and will send an email if it exceed specific size.
it will help to find spammer scripts and delete or warn users to stop bots from using server resources.
Please feel free to improve this script and share it here if you like
php_top_mailers.sh
change +100k in script if you need to change conditions.
i add it to crontab so i will receive daily email :
0 20 * * * sh php_top_mailers.sh
i wrote s simple bash script that will check php-mail.log of users and will send an email if it exceed specific size.
it will help to find spammer scripts and delete or warn users to stop bots from using server resources.
Please feel free to improve this script and share it here if you like
php_top_mailers.sh
Code:
#!/bin/sh
EMAIL="[email protected]"
TOPS=`find /home/*/.php/php-mail.log -type f -size +100k`
TOPCOUNT=`wc -l <<< "$TOPS"`
if [ "$TOPCOUNT" -gt "1" ];then
TEXT="$TOPS"$'\n\n\n'`echo "$TOPS" |xargs tail -n 10`
mail -s "Top php mail senders" $EMAIL <<< "$TEXT"
echo "$TEXT"
fi
i add it to crontab so i will receive daily email :
0 20 * * * sh php_top_mailers.sh
Last edited: