Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
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 '12 at 9:17

3 Answers 3

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.

share|improve this answer

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
share|improve this answer
    
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 '12 at 9:12

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):

/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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.