This was going to be a comment on Clausi's answer (which I believe is the most "correct" from a system administration viewpoint, in my opinion) but it bloomed into something too big to fit in the comment box.
Clamscan has a fixed amount of work to do so limiting it to a certain speed means it's just going to take longer. It's going to hold the CPU in contention for longer.
Allow it to run as fast as it can means you use your CPU to its fullest. Making it very "nice" means it'll let other processes do their work before its own. This means if there are lots of other busy processes, yes, it'll take a long time to do its own work but if there's nothing on there, it'll just chunk through its workload.
Install cpulimit
It provides different methods of limiting the CPU usage of a process
foo
to say, 20%By its process-name:
sudo cpulimit -e foo -l 20
.By its absolute path name:
sudo cpulimit -P /usr/bin/foo -l 20
By its PID:
pidof foo
. (say, it outputs 1881)sudo cpulimit -p 1881 -l 20
Just as an alternative to cpulimit:
You could start clamscan with the nice-command, e.g.
nice -n 19 clamscan
.See
man nice
for details.It does NOT limit the CPU, but it does lower the priority of the process.
Also there is
renice
to alter the priority of running processes.If you're running clamd with systemd, you could use the
CPUQuota
option.Edit
/lib/systemd/system/clamav-daemon.service
to include this line in the[Service]
section:Then restart the service
This was going to be a comment on Clausi's answer (which I believe is the most "correct" from a system administration viewpoint, in my opinion) but it bloomed into something too big to fit in the comment box.
Clamscan has a fixed amount of work to do so limiting it to a certain speed means it's just going to take longer. It's going to hold the CPU in contention for longer.
Allow it to run as fast as it can means you use your CPU to its fullest. Making it very "nice" means it'll let other processes do their work before its own. This means if there are lots of other busy processes, yes, it'll take a long time to do its own work but if there's nothing on there, it'll just chunk through its workload.
This topic can be useful: HOWTO: Set maximum CPU consumption in percentage by any process