For those wanting to limit CPU load and/or IO load when running clamav ; I suppose it is already known by a few (if not everyone) but it may still help some...
On ClearOS, Clamav scanning is scheduled by /etc/cron.d/app-antivirus.
| Code: |
0 2 * * * root /var/webconfig/scripts/avscan.php >/dev/null 2>&1
|
In this case, clamscan is called by the php script everyday at 02:00.
/var/webconfig/scripts/avscan.ph is calling /var/webconfig/scripts/avscan.inc.php. The simple trick to limit CPU and I/O load is then to edit the script /var/webconfig/scripts/avscan.inc.php and replace the line :
| Code: |
define('AVSCAN_SCANNER', '/usr/bin/clamscan');
|
by the following one :
| Code: |
define('AVSCAN_SCANNER', 'ionice -c3 nice -n 19 /usr/bin/clamscan');
|
ionice will limit the I/O exchange (idle mode ; please have a look at the man page)
nice will specify a low nice for clamscan (19 rather than 0 which is the default ; please have a look at the man page)
For the ones running their own backups (rsync, rsnapshot, ...), it make sense to ionice and nice these processes too...
Regards,
Xavier.