How to Fix High CPU Usage 100% by Clamd and Amavis

If you notice that your server’s load is consistently high and processes like amavis and clamd are consuming excessive CPU time, there are steps you can take to resolve the issue. Here’s a quick solution to fix the problem:

  1. Stop the clamd service:

    systemctl stop clamd.service
    
  2. Remove the clamd socket file:

    rm -f /var/run/clamd.amavisd/clamd.sock
    
  3. Start the clamd service again:

    systemctl start clamd.service
    

Sometimes, clamd may fail to open the appropriate socket, causing the high CPU usage. By removing the clamd.sock file, it can create a new socket and resolve the issue.

If the above steps don’t resolve the problem, it’s recommended to check the postfix log for additional clues. You can do this by running the following command in the Terminal:

tail -100 /var/log/maillog | grep clamd

The maillog file contains entries related to various components such as Postfix, Opendkim, Spamassassin, Amavis, and Clamd. Using the grep command helps filter the log entries containing the string ‘clamd’, making it easier to identify the underlying cause of the problem.

By following these steps and investigating the postfix log, you should be able to address the high CPU usage issue caused by Clamd and Amavis.