I required to know from experts, how can we run Clam Antivirus (https://www.clamav.net/) and auto scan at a certain time on a Linux machine. I don't know how this will be done, I need to create a crontab, or is there any configuration available with Clam Antivirus?


You could use a crontab. Personal preference is to write a custom script to be called by cron and execute it so as to write a log file also in the process.

#! /bin/bash
scantime=$(date -u +%H) 
#writes hour of scan, assuming to be run every 6 hours
fileout="$HOME/clamav-$(date -u +'%Hh-%d-%Y').log"

path="/var $HOME/Downloads"

for i in $path; do
    echo "Starting hourly scan of $i
    clamscan -r --bell -i $i >> $fileout

and then add 0 0 0/6 1/1 * ? * /path/to/script to crontab -e. This will run the script every 6 hours.

  • What is clamscan? is it the real name of ClamAV process? I have not installed ClamAV, can you just give me quick shot on steps assisting to install on RHEL or Ubuntu. – Muhammad Hannan Aug 6 '18 at 2:38
  • Please read the official documentation for help with installation. Clamscan is a command line utility that performs a scan. – thatgeeman Aug 6 '18 at 2:52
  • this script should be saved like scanner.sh or just scanner? Or it doesn't matter. – Muhammad Hannan Aug 6 '18 at 3:21
  • Does not matter – thatgeeman Aug 6 '18 at 3:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.