give a try to this one
#!/usr/bin/perl -w
use File::Temp qw(tempfile);
use strict;
use esmith::ConfigDB;
my $db = esmith::ConfigDB->open_ro or die "Couldn't open ConfigDB";
my $filesystems = $db->get_prop("clamav", "FilesystemScanFilesystems") || '/';
my $MailReport = $db->get_prop("clamav", "FilesystemScanReportTo") || 'admin';
# could be based on FilesystemScan property value (daily,weekly) and /or last scan date.
my $history2scan = $db->get_prop("clamscan", "HistoryToScan") || '365';
my @clamscan_opts;
push @clamscan_opts, " --recursive --infected --stdout";
push @clamscan_opts, " --log /var/log/clamd/clamscan.log";
my $quarantine_dir = $db->get_prop("clamav", "QuarantineDirectory") ||
"/var/spool/clamav/quarantine";
my @exclude = split /,/, ($db->get_prop("clamav", "FilesystemScanExclude") ||
"/proc,/sys,/usr/share/doc");
push @exclude, $quarantine_dir;
push @clamscan_opts, " --exclude=$_" for (@exclude);
push @clamscan_opts, " --no-html"
if ($db->get_prop("clamav", "ScanHTML") || "yes") eq "no";
push @clamscan_opts, " --no-mail"
if ($db->get_prop("clamav", "ScanMail") || "yes") eq "no";
push @clamscan_opts, " --move=$quarantine_dir"
if ($db->get_prop("clamav", "Quarantine") || "disabled") eq "enabled";
push @clamscan_opts, "--official-db-only=yes"
if ($db->get_prop("clamav", "FilesystemScanUnofficialSigs") || 'no') ne "yes";
my ($fh, $temp_list_file) = tempfile(CLEANUP => 1);
# Safely execute 'find' to list the files changed within the history window
my $find_cmd = "nice find $filesystems -ctime -$history2scan -type f";
open(my $find_fh, "-|", $find_cmd) or die "Failed to execute find: $!";
while (<$find_fh>) {
print $fh $_; # Write each file path into the temporary file
}
close($find_fh);
close($fh);
my $clamav_binary = "/usr/bin/clamscan";
my $log_file = "/var/log/clamd/smeserver-clamscan.log";
my @cmd = (
"nice", $clamav_binary,
@clamscan_opts,
"--file-list=$temp_list_file"
);
push @cmd, "2>", $log_file;
open(my $clam_fh, "-|", join(" ", @cmd)) or die "Failed to launch ClamAV scan: $!";
my @report = <$clam_fh>;
close($clam_fh);
my $hostname = $db->get_value("SystemName") . "." .
$db->get_value("DomainName");
my $date = localtime;
open MAIL, "| /bin/mail " .
"-s \"[$hostname] Clam Antivirus Scan Results - $date\" $MailReport";
print MAIL @report;
close MAIL;