Script to Automate Clamscan: Easy Steps

script to automate clamscan
ClamAV is an open-source antivirus engine designed for detecting malicious threats. This article will help you to automate Clamscan using script.

Setting up ClamAV cron is an easy task, and a developer called “Stefano Stagnaro” uploaded a great cron script called “clamav-cron” in Google codes that will update ClamAV scan the system and will send a brief report via email. Please follow the below steps to set this.

Go to “/opt” ,download the “clamav-cron” and give execute permission.

cd /opt
wget -O /usr/local/bin/clamav-cronchmod 755 /usr/local/bin/clamav-cron


Open the “/usr/local/bin/clamav-cron” and edit user information.

vim /usr/local/bin/clamav-cron
# Notification email recipient:
CV_MAILTO="your email ID here"
# Notification email secondary recipients:
CV_MAILTO_CC="cc mails here"
# Notification email subject:
CV_SUBJECT="Desired Subject line here"


As you can see, there are several customization options available. You can also add your codes and scan options if required. If you want an email alert each time a scan is complete, make sure you edit and add correct details in the above section. If you don’t want an email alert, make sure you comment “CV_MAILTO, CVMAILTO_CC and “CV_SUBJECT”. This will be using the default system mail function, so this will work without any further modification.

Set a cron job. I’m going to set a cron job to run this task every Saturday at 11.45 PM.

crontab -e


Add the lines at the end.

45 23 * * 6 /usr/local/bin/clamav-cron /


Restart cron service.

/etc/init.d/crond restart


That’s it!! You have set up the ClamAV cron script. This will automate the Clamscan process.

Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Linux Management Services

Focus on your business, and let us take care of your Linux Servers!
From what you are reading, it seems you are interested in Linux and related technologies. If you have a moment to spare, please take a look at our Linux Management Services plan, which might interest you even more!
Linux Management Plan

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.