0

I recently had to stand in for a sysadmin at our company. I have some Linux/Unix knowledge, but not nearly enough to be comfortable in this spot, but that is only a part of the problem.

One of the servers I have to manage has developed an acute shortage of disk-space. Now I know there various web-services write their logs, and what each of those logs contain. There is however no well defined dating mechanism for these logs. Some of them contain just a months or a weeks amount of logs, some contain a years worth.

What is the worst thing, is that all of them have a .lck file. Now I can see, that there is only on, that has been recently modified (today) and that seems to be the current file.

My question is, is it safe to try and delete the .lck files for the older log files and archive them?

The log files are created by Java and log4j on a CentOS server.

Janis Peisenieks
  • 4,938
  • 10
  • 55
  • 85
  • As long as you are backing these up before you delete them, I can't see it causing a huge problem. You could try removing write access to all users except root first. – Alex W Jul 12 '12 at 13:14

1 Answers1

0

I would argue that the question about safety is purely academic - if there is such a severe shortage of space, then something will fail sooner or later. It will become necessary to clean up those files, like it or not. It might make sense to make use of any redundancy infrastructure or to schedule some maintenance time to take down the various services if safety is absolutely critical, in order to deal with this problem before it comes calling at night.

I would first suggest going through all servers and applications and enable any log rotation schemes that are natively supported, e.g. by log4j.

For the rest, it would be necessary to set up an external log rotation system, such as a combination of logrotate and cron to keep the space used up by logs at a reasonable size. Then the log files and the corresponding services should be watched for some time, looking for unexpected defects, such as:

  • Log files that are still in use after being deleted

  • Applications that continue writing at some random offset after the file has been re-created

  • Applications that just break.

  • ...

Community
  • 1
  • 1
thkala
  • 84,049
  • 23
  • 157
  • 201