Hostxpeed
Login Get Started →
Security

How to Set Up Daily Virus Scan

5 min read
24 views
Jun 10, 2026

Step 1: Create Scan Script

sudo nano /usr/local/bin/daily-virus-scan.sh

Add:

#!/bin/bash
SCAN_DIR="/home /var/www"
LOG_FILE="/var/log/clamav/daily-scan.log"
clamscan -r --log=$LOG_FILE $SCAN_DIR
if grep -q "FOUND" $LOG_FILE; then
echo "Malware found on $(date)" | mail -s "Virus Scan Alert" admin@example.com
fi

Step 2: Make Executable

sudo chmod +x /usr/local/bin/daily-virus-scan.sh

Step 3: Add Cron Job

sudo crontab -e

Add:

0 3 * * * /usr/local/bin/daily-virus-scan.sh

Was this article helpful?