Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then 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.
Use logrotate to compress and archive old logs from time to time (put it in a cron job and be done with it) and start over with a new empty one. This goes not only for the syslog but other logs as well (mailers, and so on).
I already use logrotate for the log files, everything is running fine there except for /var/log/messages.
Well, fix your logrotate scripts to include messages, etc..
Its controlled by syslog, so if most of the other files are getting rotated out and writing after syslog is restarted, I see no reason why messages wouldn't work as well.
I restart Redhat in the 'rescue' mode and mounted the partition (read/write) under /mnt/sysimage, but even then it is not possible to remove the file /var/log/messages (/mnt/sysimage/var/log/messages).
I renamed the log-directory to oldlog and created a new log-dir, rebooted the server and now it is possible to remove the 'new' log file from /var/log/messages, but it is still not possible to remove the file /var/oldlog/messages.
Is this a corrupt file ? Does anyone know how to deal with these files ??
I restart Redhat in the 'rescue' mode and mounted the partition (read/write) under /mnt/sysimage, but even then it is not possible to remove the file /var/log/messages (/mnt/sysimage/var/log/messages).
I renamed the log-directory to oldlog and created a new log-dir, rebooted the server and now it is possible to remove the 'new' log file from /var/log/messages, but it is still not possible to remove the file /var/oldlog/messages.
Is this a corrupt file ? Does anyone know how to deal with these files ??
I think you took about 10 steps too many and 30 minutes that should have taken you 3 steps and 2 minutes..
Of course messages is going to be locked, its usually gettin written to quite often. What you should have done was stop syslogd, remove file, restart syslogd.
And now if you never want to encounter this problem again, setup and configure logrotate properly, it will do all of this for you.. (even without rebooting your system)
Originally posted by trickykid I think you took about 10 steps too many and 30 minutes that should have taken you 3 steps and 2 minutes..
Of course messages is going to be locked, its usually gettin written to quite often. What you should have done was stop syslogd, remove file, restart syslogd.
And now if you never want to encounter this problem again, setup and configure logrotate properly, it will do all of this for you.. (even without rebooting your system)
Trickykid:
Thanks for your reply, but:
-i already used logrotate and it did work for about half a year very well (for all log-files).
-i know that you should stop de syslog daemon first, before you can dan anything to the file (messages).
I experienced problems with the file a couple of weeks ago, the other log-files are not having the problem, logrotate works still fine for these.
Did you check if there were any attributes set for the directory/file? lsattr
The existence of attributes are often forgot about. They are actually quite handy sometimes.
Echo > /var/log/messages (ditto >>) won't clean up anything. The > is a re-direct to send something to /var/log/messages. The clean messages up (I assume you mean to clean out the file and leave an empty file), do this: su to root, then /dev/null > /var/log/messages. This command basically says to overwrite messages with nothing (leaves an empty file).
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.