How to Install ClamAV Antivirus and Configure Daily Scanning on CentOS

clamav_logoClamAV is an open source (GPL) antivirus engine designed for detecting Trojans, viruses, malware and other malicious threats on Linux.

Install EPEL repository
For 64-bit
~# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

For 32-bit
~# rpm -Uvh http://mirror.overthewire.com.au/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Install CLAMAV
~# yum install clamav clamd

Start Daemon
~# /etc/init.d/clamd start

Daily Scan Scheduling
Create a new cron file in /etc/cron.daily/ directory. If you want to run scan weekly, then file location will be /etc/cron.weekly/

~# vim /etc/cron.daily/clamav_scan
Add following piece of code into clamav_scan file.

#!/bin/bash
SCAN_DIR=”/home”
LOG_FILE=”/var/log/clamav/weeklyscan.log”
/usr/bin/clamscan -i -r $SCAN_DIR >> $LOG_FILE

Exit vim editor and give this script executable permissions.

Execute Permission::
~# chmod +x /etc/cron.daily/

Update ClamAV’s signatures
~# /usr/bin/freshclam

Done! [OK]

Content credit :o2cinemas