How to install ClamAV on Debian and set daily scan + report

Valic —  December 15, 2012 — Leave a comment

ClamAV is a virus scanner for Linux/Unix file systems. In this tutorial I will show you how to install ClamAV on Debian and how to keep it updated and also how to do a daily scan.

ClamAV will report only if infected threats are found. You can also scan only specific folders and remove infected files automatically.

Step1. Install ClamAV:

apt-get install clamav

Step2. Update virus database:

freshclam is a virus database update utility for ClamAV antivirus.
Update virus database simply by running the following command:

freshclam

Step3. Setting the daily scan:

You can set a cronjob that will update virus database and afterwards run a full scan on your system. Let’s say that you want to run the full scan at 3:00AM.

0 3 * * * /usr/bin/freshclam --quiet; /usr/bin/clamscan --recursive --no-summary --infected / 2>/dev/null

  • –quiet  option from freshclam will only output error messages;
  • –recursive will scan directories and subdirectories recursively;
  • –no-summary – this disables the summary from the end of scanning;
  • –infected – will print only infected files;
  • 2>/dev/null -  will report only the infected files and errors will be left out of the report.

This cronjob will not remove the infected you will have to it manually.
Make sure that your cron is configured to send mails to you with the output of the cronjobs. You can do that by adding this [email protected] at the beginning of the cron file.

Enjoy.

Valic

Posts Twitter Facebook

Editor in Chief at Debian-Tutorials, Linux enthusiast.

No Comments

Be the first to start the conversation.

Leave a Reply