Security bash Advanced

ClamAV Malware Scanner Cron

Run ClamAV on upload directory and quarantine infected files automatically.

bash
#!/bin/bash
UPLOAD_DIR=/var/www/uploads
QUARANTINE=/var/quarantine

clamscan --recursive \
         --infected \
         --move=$QUARANTINE \
         --quiet \
         $UPLOAD_DIR

if [ $? -eq 1 ]; then
  echo "ALERT: Malware detected and quarantined" | mail -s "ClamAV Alert" admin@example.com
fi

Prerequisites

  • clamav
  • freshclam (signatures up to date)

Pro Tips

  • → Run freshclam daily to keep signature database current.

Was this module useful?

Share your experience — it helps the team improve.

Leave Feedback

Commercial Licensing

Acquire a production access token or template license for enterprise deployment.

Module Info

Language
bash
Level
Advanced
Read time
3 min
Published
May 2026
License
Commercial License

Newsletter

New modules every week, directly to your inbox.