How to install CLAMAV with update DB script and Scanning on CentOS?
Script to update clamav and Start scanning via Cron
So, lets create a script to update clamav db and then start scanning via Cron Daemon.
vi /etc/cron.daily/clamav_scan
#!/bin/bash # ———————————————————————- # Virus scan with ClamAV # ———————————————————————- # Disabling PATH improves the security of the script unset PATH # Declare the variables ECHO=/bin/echo; DATE=/bin/date; FRESHCLAM=/usr/bin/freshclam; CLAMSCAN=/usr/bin/clamscan; LOG_FILE=/var/log/clamav/clamscan.log; SCAN_FOLDER=/home;
$ECHO Complete system virus scan starting >> $LOG_FILE; $DATE >> $LOG_FILE; $ECHO \* >> $LOG_FILE;
$FRESHCLAM >> $LOG_FILE;
$CLAMSCAN -ri $SCAN_FOLDER >> $LOG_FILE;
$ECHO \* >> $LOG_FILE; $ECHO Complete system virus scan finished >> $LOG_FILE; $DATE >> $LOG_FILE; $ECHO \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* >> $LOG_FILE; |
Note:
- As per this script you have to manually check log file for any possible infective files.
- You can change directory for scanning by modify SCAN_FOLDER=/home;