How to schedule ClamAv to perform a daily scan

12,275

I would use cron for this instead of strictly using bash. In the directory /etc/cron.daily/ create a small script clamavscan.sh that looks like:

#!/bin/sh
clamscan /home/username/

Then be sure to make the script executable with chmod +x clamavscan.sh. This should run the clamscan of your home directory once daily at 6:25 (as you can see in the file /etc/crontab).


To have ClamAV scan you entire machine, you should just be able to run clamscan /, although this might require root privileges to really scan everything.

Share:
12,275

Related videos on Youtube

OverMorrow
Author by

OverMorrow

Updated on September 18, 2022

Comments

  • OverMorrow
    OverMorrow over 1 year

    I want to schedule a daily scan in my Home directory using ClamAv. Can anybody explain me how to perform such task using a bash script? I don't need to scan mails, just Home directory and maybe other directories. Thank you

    P.s.: I don't really need it, but is there a way to perform a scan on the whole pc?

  • OverMorrow
    OverMorrow about 8 years
    What will ClamAv do if it finds some threats?
  • Mike Pierce
    Mike Pierce about 8 years
    I don't know what ClamAv's default behavior is. You could probably set ClamAv to automatically delete/quarantine/whatever the threats so you don't have to deal with them. Otherwise, if you want to make the call manually, you could make a slightly more sophisticated clamavscan.sh script that somehow alerts you to make a decision. At the very least you can redirect the output of the clamscan so you have a logfile to check for threats.