Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I am using an older Dell laptop with only 26GB HD and running Ubuntu 11.04
I am getting messages telling me my HD is running out of room. As I explored this, I found that the log under var is using 20.1GB and growing a bit each time I turn on the computer. Can I safely delete the files in this log?
Thanks for any help you can give me.
Mike
Traditionally the /var/ directory is set as a separate file system to prevent the hard drive from filling up and causing issues so if it does fill up it only affects that file system. /var/ is used mostly for storing log files of which they can usually be removed. However, the info inside may be of use depending upon the app that is logging it. Most apps will have a config file that you tell it what to log, for instance Apache HTTP web server has different levels you can set to log from warn to error, which one you select will tell Apache how much info to log and most apps have a similar directive you can modify to prevent this from re-occurring.
The main logs in /var/log are those used by the system (with /var/log/messages being the main one). You can not simply delete logs usually because they are in active use by a process. When you delete an open file it deletes only the name but NOT the inode so doesn't free up space until the process goes away.
Instead log rotation routines such as that described in the above link should be used. By default RHEL5 does log rotation for several of the logs (including messages) in /var/log so you shouldn't need to delete things. It may be someone has adjusted your rotation or that you are getting so many messages that standard rotation doesn't suffice. In which case you might want to investigate WHAT is in the logs rather than how large they are. Perhaps you have something too verbose turned on? Something logging to this log that ought to log elsewhere? Some issue that you can fix to stop dozens of log messages? It doesn't help you to clear the size of the log if the real problem is something like the log being full of messages telling you / is full and you're not addressing that underlying issue.
I am using an older Dell laptop with only 26GB HD and running Ubuntu 11.04
I am getting messages telling me my HD is running out of room. As I explored this, I found that the log under var is using 20.1GB and growing a bit each time I turn on the computer. Can I safely delete the files in this log?
Thanks for any help you can give me.
Mike
If you don't care for what's in these logs, yes you can delete the logs, but your problem will remain and make you do it over and over again after some time. I'd start with finding the log file which grows so fast.
Code:
cd /var/log
ls -lh
you'll see either a big file or several small (100MB) but with a common name. Examine them and see what is the problem. The file without dot number at the end is most recent and you should be able to see the cause by
Code:
tail -n20 <file_name>
______________________________________
Please also make sure you don't have an empty CD in your CD-ROM. I had this problem recently, what I've done was:
removed an empty CD from the drive
deleted old logs
Code:
rm -rf /var/log/syslog.*
removed unnecessary lines from the most recent syslog file with
Code:
sed -i "/Make sure there is a disc in the drive./d" /var/log/syslog
Doing an rm -rf to your log directory is not advised in most cases. Alot of times you will see issues with processes, esp syslog and other logging processes, removing and/or rotating log files but the process never kills so the inodes do not get removed/updated properly. This can cause your df -h to show 100% usage but du -sh will show much less. If this is the case you simply need to find the process that has the log file open:
Code:
ps auxww | grep /var/log/
Then you can kill the process or restart the associated daemon and the inodes should get removed properly and your disk usage be read correctly. This happened to me recently with VNC server and its logging.
Doing an rm -rf to your log directory is not advised in most cases. Alot of times you will see issues with processes, esp syslog and other logging processes, removing and/or rotating log files but the process never kills so the inodes do not get removed/updated properly. This can cause your df -h to show 100% usage but du -sh will show much less. If this is the case you simply need to find the process that has the log file open:
Code:
ps auxww | grep /var/log/
Then you can kill the process or restart the associated daemon and the inodes should get removed properly and your disk usage be read correctly. This happened to me recently with VNC server and its logging.
Right! Two remarks:
- it's a laptop, which I assume is restarted pretty often
- rm -rf /var/log/syslog.* will remove old rotated logs only, not the one syslog is writing to...
Thankyou for all the responses; however, I have been unable to solve the problem. I am not very literate in Linux code and was unable to get any response by pasting the suggestions into the terminal command box. What I will do at the completion of this message is to "nuke" the HD and reload Ubuntu. The only information I keep on the HD is the bookmarks in Firefox, which I can save and reload. I suspect that this problem will occur again in the future, but perhaps by then I can figure out how to cure or prevent it. It all seems to be tied into the "log" file in "Var", which just keeps growing. There are several files that seem to duplicate with extensions numbering 1 and upward to 10 or more. Example: Alternatives.log.5 gz and dmesg.1.gz. Although these are not large files, they keep growing in number.
Thanks again for your responses. Catch you on the "other side".
Mike
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.