1819766 Members
3119 Online
109606 Solutions
New Discussion юеВ

finding large files

 
SOLVED
Go to solution
Chris Fadrowski
Super Advisor

finding large files

Can someone refresh me on the command i can use to find files that are a certain size or bigger? My /var keeps filling up. I would like to find all files 10mg and bigger but i forgot the command to use. ( i know to use find ) but just don't know the syntax.
7 REPLIES 7
James A. Donovan
Honored Contributor
Solution

Re: finding large files

find /var -size +10000000c
Remember, wherever you go, there you are...
Jeff Schussele
Honored Contributor

Re: finding large files

Hi Chris,

find /var -size +10000000c -print

for files > 10M

Or try the following to see hogs in descending order

du -akx /var | sort -nr | more

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
Todd McDaniel_1
Honored Contributor

Re: finding large files

one of my co-workers wrote this a loong time ago.

usage:
./bigfiles
./bigfiles /root 1000000

#cat bigfiles
------------------------------cut here-------------------------
# cat bigfiles
# To find any file over a certain size in a given directory
# Primarily used to locate files which might be running a filesystem out of
# space.
#
# First parameter is the filesystem or directory to begin the search from
# Second parameter is the size of the file, in characters, to find
#
if [ $# -eq 2 ]
then
if [ -d $1 ]
then
#ls -l `find "${1}" -xdev -size +"${2}"c -print`
find "${1}" -xdev -size +"${2}"c -print > /tmp/crslist$$
if [ -s /tmp/crslist$$ ]
then
ls -l `cat /tmp/crslist$$`
else
echo "apparently no files that large in "${1}
exit
fi
else
echo "$1 is not a directory...try again"
exit
fi
else
echo "\n\nbigfiles requires 2 parameters..."
echo "\tthe first is the beginning directory"
echo "\tthe second is the size of the file to search for\n\n"
fi
Unix, the other white meat.
Michael Tully
Honored Contributor

Re: finding large files

find /var -size +1000000c -print
Anyone for a Mutiny ?
SS_6
Valued Contributor

Re: finding large files

Many friends have given syntax for find command and I will also suggest to do cleanup to reduce /var. Do man on cleanup command, you can preview it and than do it. You may not have to delete anything manually. Its very useful.
By providing solutions I am helping myself
Bill Hassell
Honored Contributor

Re: finding large files

Very common mistake (looking for big files). /var is a VERY dynamic (variable) filesystem and will easily fill up causing serious problems. Since there many different subsystems that use /var, the first thing to do is to find big DIRECTORIES, not big files. This will isolate the real reason for /var filling up. Use this command:

du -kx /var | sort -rn | more

The few directories at the top of the list are the ones to look at. There may be a directory that has 10,000 files that are 1meg in size...that's 10Gb but not a single big file at all. Here are some typical scenarios:

/var/adm/sw (patches and installed s/ware--use cleanup)

/var/adm (logfiles)
/var/spool/lp/request (spooler files)
/var/mail(email files)

Once you've found a big directory, use ll to sort by size:

ll | sort -rnk5 | more

Now you can effectively cleanup the results. If your /var is less than 1Gb, double it and then create a trim script for cron to run each day.


Bill Hassell, sysadmin
Juli├бn Esteban Aimar
Occasional Advisor

Re: finding large files

find /var -size +10000000c -exec ls -l \;

this command find files > to 10 mb and list.
Bye.

J.E.A.