This is an easy to configure bash script, for those who want to schedule definition updates, scanning, and e-mail a report upon any virus detection or clamav-cron errors 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/
- Update the ClamAV virus database (freshclam).
- Perform personal system scan (clamscan/clamdscan).
- Send a brief report upon virus detection via e-mail (sendmail).
Without any knowledge about ClamAV configuration files (such as clamd.conf or freshclam.conf). You only need to configure the e-mail address(es) that will receive the report.
The ClamAV engine (clamav).
A mail server (sendmail). required for sending mail reports).
The ClamAV daemon (clamd).
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="[email protected]"
# Notification e-mail recipient (must be valid):
CV_MAILTO="[email protected]"
# Notification e-mail secondary recipients (must be valid):
CV_MAILTO_CC="[email protected]"
# 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).