5

I deleted a 7GB apache2 other_vhosts_access.log.1 to free up some space on our server. Basically I deleted all but the most recent access logs. The largest was uncompressed - I assume it hadn't been through logrotate (which is running).

Running a df -h shows no extra space and I have tried every combination of apache/apachectl restart/reload/graceful etc.. as mentioned in other questions - with no result. lsof doesn't show the file open either.

1
  • 1
    What do your partitions look like? I wonder if you might be looking in the wrong place for your free space.
    – Ladadadada
    Nov 7, 2012 at 9:17

4 Answers 4

4

more than likely you have deleted the logs but apache has locked them up.

You should use lsof and look for (deleted). IBM guide here. The way to fix is to restart the apache process to release the file.

3

Try to copy /dev/null to your logfile. This should truncate your file without closing the file handle apache is holding...

cp /dev/null other_vhosts_access.log.1
1
  • The principle is sound but if he's already deleted them, he can't do that. Writing to the open filehandle in /proc may work but I've never tried that.
    – Ladadadada
    Nov 7, 2012 at 9:12
1

I had the same problem and I solved as follows.

PROBLEM:

I deleted manually access_log and error_log in directory /var/www/vhosts/mywebsite/logs/mywebsite1/ to free up space, but even if the files are disappeared, space is not freed.

SOLUTION:

I used lsof sorted by size to search big file (command found here):

lsof -s | awk '$5 == "REG"' | sort -n -r -k 7,7 | head -n 100

I found the two big files access_log and error_log in another path (note the difference with previous path):

/var/www/vhosts/system/mywebsite1/logs/

I reset these two files with command:

:>/var/www/vhosts/system/mywebsite1/logs/access_log

:>/var/www/vhosts/system/mywebsite1/logs/error_log

The files have been emptied and the space is freed.

Hope it can be helpful.

0

In my case, I needed to restart rsyslog, which is the one that handles logs on my ubuntu system and it did released all the disk space.

This can be restarted running sudo service rsyslog restart or if you are on 16.04+ with sudo systemctl restart rsyslog.

You must log in to answer this question.

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