Daily clamscan

Script that scans every public_html in the server using clamav and sends the results by email.

#!/bin/bash
SUBJECT=”VIRUS at `hostname`!!!”
EMAIL=”mail@mail.com”
LOG=/tmp/clam_scan.log
rm -f ${LOG};
check_scan () {
if [ `cat ${LOG} | grep FOUND | grep -v 0 | wc -l` != 0 ]
then
EMAILMESSAGE=`mktemp /tmp/virus-alert.XXXXX`
echo “`cat ${LOG}`” >> ${EMAILMESSAGE}
mail -s “${SUBJECT}” “${EMAIL}” < ${EMAILMESSAGE}
fi
}
clamscan -ri /home/*/public_html/ –log=${LOG} > /dev/null
check_scan

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s