Is it possible to check the progress of of a currently running clamAV scan?

I have searched around but not found a possible solution to this so far. I have an ongoing scan which I thought would've been finished at certain time, but unfortunately it has not. So I am wondering if there's a way to check the scan progress of this ongoing progress.


AFAICT, this is not possible—you can either have all scanned files printed to the console, or just print infected files. Then at the end, ClamAV will print a summary. I haven't been able to find a way to get any ongoing statistics.

The only way I could imagine hacking it to do this would be:

  1. First, count all files recursively in the directory(ies) that will be scanned by ClamAV, then store that number in a variable.
  2. Run ClamAV wrapped in a script that counts the lines output, and compares that to the count from step 1.

I tried doing this quickly one time, but couldn't get it working well enough for an automated Jenkins job I set up... so I eventually gave up on it. Sorry :(


This is an old, answered thread but I wanted to try geerlingguy's idea (whom I am a fan :-)) and in case others end up here provide a codified solution.

If you want to scan the folder foo for example, you start the scan with:

clamscan -r foo | tee /tmp/scan.log

or

clamscan -r foo > /tmp/scan.log

You can then run the following script with the arguments of the folder being scanned and the log file, in this example

status.sh foo /tmp/scan.log

Where the contents of the status.sh file is:

#!/bin/bash
folder=$1
log=$2
numFiles=`find $folder -type f | wc -l` 
echo $numFiles files to be processed

numProcessed=`wc -l $log | awk '{print $1'}`
percent=`echo "scale=2;$numProcessed*100./$numFiles." | bc`
echo $percent percent complete.

One could combine running of the scan and checking the status into a single script if needed.