ClamAV crashes after some time

Hi,

I’m running Virtualmin 4.08.gpl on an Ubuntu 14.04 LTS t2.micro AWS instance.
I have all the “regular Virtualmin servers” running but the ClamAV server always crashes after some hours and I need to reboot the system.
The t2.micro instance have 1GB RAM but the result of /var/log/clamav/clamav.log when i try to restart the ClamAV service (/etc/init.d/clamav-daemon restart) is:

Sat Jul 12 18:40:10 2014 -> +++ Started at Sat Jul 12 18:40:10 2014 Sat Jul 12 18:40:10 2014 -> clamd daemon 0.98.1 (OS: linux-gnu, ARCH: x86_64, CPU: x86_64) Sat Jul 12 18:40:10 2014 -> Log file size limited to 4294967295 bytes. Sat Jul 12 18:40:10 2014 -> Reading databases from /var/lib/clamav Sat Jul 12 18:40:10 2014 -> Not loading PUA signatures. Sat Jul 12 18:40:10 2014 -> Bytecode: Security mode set to "TrustSigned". Sat Jul 12 18:40:15 2014 -> Loaded 3499334 signatures. Sat Jul 12 18:40:16 2014 -> LOCAL: Unix socket file /var/run/clamav/clamd.ctl Sat Jul 12 18:40:16 2014 -> LOCAL: Setting connection queue length to 15 Sat Jul 12 18:40:16 2014 -> ERROR: daemonize() failed: Cannot allocate memory Sat Jul 12 18:40:16 2014 -> Socket file removed.

Any ideas?

Looks like you don’t have enough memory, what is the output of “free -m”?

With ClamAV running again (after a reboot):

total used free shared buffers cached
Mem: 992 908 84 6 15 205
-/+ buffers/cache: 687 305
Swap: 0 0 0

Yeah, memory is quite full and you don’t have swap space. You might need to upgrade your memory or ask your hoster to make swap available.

This creates a fake swap file on CentOS 6, this should help. EC2 does not have swap available. I use this on some virtual systems that run database software that requires swap.

dd if=/dev/zero of=/swapfile bs=1M count=512 mkswap /swapfile swapon /swapfile

free -m should now show the 512MB swap

add this to /etc/fstab to enable swap at boot time
/swapfile swap swap defaults 0 0
If you don’t then you need to run “swapon /swapfile” after every reboot