Ubuntu – How to schedule ClamAv to perform a daily scan

15.10antivirusbashclamav

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?

Best Answer

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.

Related Question