Clamd High CPU usage 100% - Solved Solution



  • This is temporary solution by limiting the clamd cpu usage:

    edit clamd systemd service file :

    nano /usr/lib/systemd/system/clamd.service
    

    if upper location doesn't have the systemd file try below location

    nano /etc/systemd/system/multi-user.target.wants/clamd.service
    

    Find the [service] section and add this configs below after the last line :

    For CPU Dual core and more :

    IOSchedulingPriority = 7
    CPUSchedulingPolicy = 5
    MemoryLimit=128M
    CPUQuota=10%
    Nice = 19
    

    for CPU single core or less power cpu :

    IOSchedulingPriority = 7
    CPUSchedulingPolicy = 5
    MemoryLimit=128M
    CPUQuota=5%
    Nice = 19
    

    then reload the systemd daemon and restart clamd service

    systemctl daemon-reload
    systemctl restart clamd
    

    EXAMPLE :

    # nano /usr/lib/systemd/system/clamd.service
    
    [Unit]
    Description = clamd scanner (%i) daemon
    Documentation=man:clamd(8) man:clamd.conf(5) https://www.clamav.net/documents/
    # Check for database existence
    # ConditionPathExistsGlob=@DBDIR@/main.{c[vl]d,inc}
    # ConditionPathExistsGlob=@DBDIR@/daily.{c[vl]d,inc}
    After = syslog.target nss-lookup.target network.target
    
    [Service]
    Type = simple
    ExecStart = /usr/sbin/clamd -c /etc/clamd.d/amavisd.conf --foreground=yes
    Restart = on-failure
    IOSchedulingPriority = 7
    CPUSchedulingPolicy = 5
    MemoryLimit=128M
    CPUQuota=10%
    Nice = 19
    
    [Install]
    WantedBy = multi-user.target
    
    

Log in to reply
 

Recent Topics