Tuesday, February 17, 2015

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.


Answer



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



No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...