script for scanning the server by using clamscan : CRON
The following script is used to scan the server for viruses present in the server by using clamscan. Note that you will need install clamscan. This script will send an email to you after completion of the scan. Mention your mail address in EMAIL_ line.
—————————————-
#!/bin/bash
EMAIL_=Your email address
ret=0
/usr/local/clamav/bin/freshclam >/dev/null
for host in $(cut -d: -f2 /etc/trueuserdomains|sed ‘s/^[ ]*//g;s/[ ]*$//g’)
do
/usr/local/clamav/bin/clamscan -ir /home/$host/public_html/ > ~/tmp.txt
grep FOUND ~/tmp.txt >/dev/null
if [ $? -eq 0 ];then
grep FOUND ~/tmp.txt > /root/clamreport/$host.report
ret=1
fi
done
if [ $ret -eq 1 ];then
msg1=”ALERT PRODUCED BY /root/clamscan.sh”
msg2=”INFECTIONS FOUND IN SERVER `hostname`”
echo -e “$msg\n$msg”|mail -s “CLAMAV ALERT FROM `hostname`” ${EMAIL_}
fi
—————————————-
You can add this script in cron.weekly, cron.daily according to your requirement.