After deleting log files, Ubuntu server still saying there is no space

My Ubuntu server has stopped due to a lack of disk space. I deleted some log files which has grown huge very quickly. But df -h still shows I have no space left. When I run du -sh /* I can see that I should have plenty of disk space left after deleting the logs.

I ran lsof +L1 and it brought up two files: /var/log/mail.log and /var/log/mail.err. These are two logs I had deleted. I restarted apache, postfix and mysql (mysql wont restart because of lack of disk space, it think) but still df -h shows no space.


In this case the files are probably managed by syslog. You may have rsyslog, sysklogd or syslog-ng. From memory I think rsyslog is the default, so try:

sudo service rsyslog restart

This should release the files, and allow them to actually get cleaned up. Until the last filehandle closes, the filesystem can't free up space.

(or you could do like a Windows admin and just reboot of course...)


You need to restart the service that created these logs, as they have a lock on these logs. eg. If it's apache, just restart apache and usage should go down.