103

I have installed clamav and I want to to update the files that it uses to identify viruses:

$ sudo freshclam

ERROR: /var/log/clamav/freshclam.log is locked by another process
ERROR: Problem with internal logger (UpdateLogFile = /var/log/clamav/freshclam.log).

What should I do with this error?

EDIT:

$ sudo lsof /var/log/clamav/freshclam.log

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
freshclam 866 clamav    3wW  REG  259,1   100134 10486045 /var/log/clamav/freshclam.log
0

5 Answers 5

142

Short answer:

You don't have to run it manually because it has been run automatically and is running in the background, that's why you receive that message.

If you want to stop the daemon and run it manually:

sudo systemctl stop clamav-freshclam.service

run it manually:

sudo freshclam

What is happening and how to handle it?

Every time when you encounter into a similar situations, errors like file x has been locked or Another process is using this file : /path/to/x you can use the lsof command to find out which process is using that file, in your case if you run:

sudo lsof /var/log/clamav/freshclam.log

You should get an output like:

COMMAND   PID   USER   FD   TYPE DEVICE SIZE/OFF     NODE NAME
abc       126   user   3wW  REG  259,1  100          1048 /var/log/clamav/freshclam.log

The abc is the name of process which is using that file, in your case it's: freshclam.

That means freshclam which you want to run has been already ran by clamav daemons.

you can use less /var/log/clamav/freshclam.log or similar commands to see what's going on.

So you don't have to run it manually anymore, it's a process to avoid any conflict and having multiple instance of a same process doing same thing at the same time.

If you want to make it stop and run it manually, then send a SIGTERM to its process, that gives the process a chance to finish its job and close itself cleanly, something like:

sudo pkill -15 -x freshclam
  • in this case sudo may be necessary.
  • 15: SIGTERM is the default

Then run it manually:

sudo freshclam

However in this case you can use:

sudo systemctl stop clamav-freshclam.service

to stop the daemon.

5
  • Will the daemon start up again after a reboot? If so, do you know the best way to prevent that? Thanks. Oct 1, 2019 at 16:44
  • 1
    sudo systemctl disable clamav-freshclam.service might be the way.
    – Ravexina
    Oct 1, 2019 at 17:50
  • Thanks, I'll try that out if it pops back up again. Oct 1, 2019 at 19:01
  • For what it's worth, this seems to take a damn long time. I've got a good machine and I've been waiting for more than an hour since installation for this update to show any signs of progress.
    – J. Mini
    Feb 27, 2022 at 22:24
  • 1
    just test the status of freshclam with sudo service clamav-freshclam status Jul 19, 2023 at 5:37
28
sudo /etc/init.d/clamav-freshclam stop
sudo freshclam
sudo /etc/init.d/clamav-freshclam start
0
15

This might be another option for this...

sudo service clamav-freshclam stop
sudo freshclam
sudo service clamav-freshclam start

Hope this helps...

1
  • This one helped me!! Thanks!
    – Nick
    Apr 4, 2022 at 18:38
1

Maybe this is the most simple answer to the question:

sudo su clamav freshclam

Obviously, freshclam is already running with the clamav user (as sudo lsof /var/log/clamav/freshclam.log tells us). Call it again in this user's name to wake it up and update the database. Then to check the success...

sudo less /var/log/clamav/freshclam.log

0

Just test the status of freshclam with

sudo service clamav-freshclam status

If it is running OK (it should show active, (running)), you don't have to do anything

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .