Linux Tips 3: Finding system files greater than a certain size

|
If you have a high traffic site and keep detailed Apache logs you may find your Apache suddenly failing for no reason and spawning a a lot of processes even though site traffic is no greater than usual. The most likely problem is that the site logs have gotten too large for Apache to handle. Two gigabytes is pretty much the max and you need to delete or shorten your log files for Apache to be happy again. When I dealt with this situation I had no idea where the files were or how many there were as the server ran multiple high traffic sites. The solution is a simple Linux command.

To find all files in your operating system that is greater than 2 gigabytes type:

find / -size +2000000k -printf "Size: %kK\tPath: %p\n"
This will find all files greater than 2 million kilobytes, aka 2 gigs, and print its actual size as well as where it resides so you can do something about it. You can update the script to work in the current directory only by replacing the first "/" with a "." and changing your file size filter by changing the 2000000 value.

0 comments:

Post a Comment