Faster multi threaded clamscan for whm and cpanel -

WordPress hosting done right. done fast. done secure

GET STARTED
Menu

Faster multi threaded clamscan for whm and cpanel

faster multithreaded clamscan

I found daily clamscan took longer and longer. Eventually it was taking all weekend, then all week.

The default scanning scans 1 domain at a time. My servers have SSD and multi cores – and can easily handle a bunch of clamscans at once.

But you don’t want to over tax your server – with too high a load.

The following script allows you to scan a number of threads at once, and it manages the load. You can set a maxtasks and max load at the top.

#!/bin/bash
maxload=6
maxtasks=4
rm -f /data/tmp/log/infections
for i in `awk '!/nobody/{print $2 | "sort | uniq" }' /etc/userdomains | sort | uniq`
 do
#echo scan $i
nice -n 19 ionice -c 3 /usr/local/cpanel/3rdparty/bin/clamscan -v -i -r /home/${i}  >>/data/tmp/log/infections &

sleep 30

while true

do

if [ `ps ax|grep -v grep|grep -c clamscan` -lt ${maxtasks} ]; then 

		if [ `uptime|awk '{print $(NF-2)}'|cut -d. -f1` -lt ${maxtasks} ]; then
			break
		else
			sleep 30
		fi
else

#	echo sleep 10
	sleep 10
fi

done




 done 


while true

do

if [ `ps ax|grep -v grep|grep -c clamscan` -gt 0 ]; then
        break
else

#       echo sleep 10
        sleep 10
fi

done

 

By on May 2nd, 2018 ,

Email or call, and we can arrange a time to chat call 0412927156 or CONTACT US TODAY!