ClamAV: clamd.ctl file is not getting created on ubuntu

Solution 1:

I faced this issue on my Ubuntu 20.04 LTS machine,

What I did was:

  1. run sudo systemctl stop clamav-daemon.service
  2. then run sudo rm /var/log/clamav/freshclam.log (sometimes it gets locked)
  3. start the service sudo systemctl start clamav-daemon.service

to ensure everything is OK run sudo systemctl status clamav-daemon.service and the output should look something like this:

➜  ~ sudo systemctl status clamav-daemon.service
● clamav-daemon.service - Clam AntiVirus userspace daemon
     Loaded: loaded (/lib/systemd/system/clamav-daemon.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/clamav-daemon.service.d
             └─extend.conf
     Active: active (running) since Sun 2020-05-03 05:03:51 EEST; 4s ago
       Docs: man:clamd(8)
             man:clamd.conf(5)
             https://www.clamav.net/documents/
    Process: 6122 ExecStartPre=/bin/mkdir -p /run/clamav (code=exited, status=0/SUCCESS)
    Process: 6124 ExecStartPre=/bin/chown clamav /run/clamav (code=exited, status=0/SUCCESS)
   Main PID: 6138 (clamd)
      Tasks: 1 (limit: 14203)
     Memory: 367.3M
     CGroup: /system.slice/clamav-daemon.service
             └─6138 /usr/sbin/clamd --foreground=true

May 03 05:03:51 user systemd[1]: Starting Clam AntiVirus userspace daemon...
May 03 05:03:51 user systemd[1]: Started Clam AntiVirus userspace daemon.

Now run sudo freshclam and check the log file (or console output)

Sun May  3 05:04:02 2020 -> --------------------------------------
Sun May  3 05:04:02 2020 -> ClamAV update process started at Sun May  3 05:04:02 2020
Sun May  3 05:04:02 2020 -> daily.cvd database is up to date (version: 25800, sigs: 2331970, f-level: 63, builder: raynman)
Sun May  3 05:04:02 2020 -> main.cvd database is up to date (version: 59, sigs: 4564902, f-level: 60, builder: sigmgr)
Sun May  3 05:04:02 2020 -> bytecode.cvd database is up to date (version: 331, sigs: 94, f-level: 63, builder: anvilleg)

Enjoy!

Solution 2:

I found that after you run the:

freshclam 

And get this error:

Clamd was NOT notified: Can't connect to clamd through /var/run/clamav/clamd.ctl: No such file or directory

You just need to run restart for the demon:

service clamav-daemon restart

And then freshclam again and all works.