This is an easy to configure bash script, for those who want to schedule definition updates, scanning, and e-mail a report upon any detection via the local MTA.
This is free software licensed under the GPLv3 and is based on the original script by Stefano Stagnaro.
You can find the original script here:
https://code.google.com/p/clamav-cron/
- Run a PHP-Antimalware-scan (PHP-Antimalware-Scanner).
- Send a brief report upon virus detection via e-mail (sendmail).
The configuration file for the scheduled task will contain scanning options for each path. You will need to customize this file to fit your server's layout.
PHP-Antimalware-Scanner (doesn't need to be installed system-wide, just put the correct path to the script in the config).
A mail server (sendmail) required for sending mail reports.
Debian/Ubuntu quick setup (debian-setup.sh)
mkdir -p /opt/clamav-cron
cd /opt/clamav-cron
wget https://raw.githubusercontent.com/yangwithinyin/clamav-cron/master/debian/debian-setup.sh
chmod 755 debian-setup.sh
FreeBSD quick setup (freebsd-setup.sh)
mkdir -p /opt/clamav-cron
cd /opt/clamav-cron
wget https://raw.githubusercontent.com/yangwithinyin/clamav-cron/master/freebsd/freebsd-setup.sh
chmod 755 freebsd-setup.sh
cd ~
wget https://raw.githubusercontent.com/yangwithinyin/clamav-cron/master/clamav-cron.sh
cp ~/clamav-cron.sh /usr/local/bin/clamav-cron.sh
chmod 755 /usr/local/bin/clamav-cron.sh
chown clamav:clamav /usr/local/bin/clamav-cron.sh
chown clamav:clamav /var/log/clamav
#============================================#
# User configuration section #
#============================================#
# Log file name and its path:
CV_LOGFILE="/var/log/clamav/clamav-cron.log"
# Notification e-mail sender (will work when invalid):
CV_MAILFROM="user@server.tld"
# Notification e-mail recipient (must be valid):
CV_MAILTO="user@maildomain.tld"
# Notification e-mail secondary recipients (must be valid):
CV_MAILTO_CC="webmaster@yourcompany.tld"
# Notification e-mail subject:
CV_SUBJECT="Your Company - ClamAV scan report"
crontab -e
45 23 * * 5 /usr/local/bin/clamav-cron.sh /
Cron will run clamav-cron every Friday at 23:45 (11:45 pm) to recursively scan the whole / tree.
At the end of task it will send a notification e-mail upon virus detection to the users specified at step 3.
For more information about crontab see the manual (e.g. man 5 crontab).