Operating System - HP-UX
1834640 Members
3314 Online
110069 Solutions
New Discussion

find cmd to search for files older than 90 days

 
SOLVED
Go to solution
Jerry_109
Super Advisor

find cmd to search for files older than 90 days

HP-UX B.11.11 U 9000/800/A500-7X

Hello All,

I need to figure out a way locate all files
under /auditlog/usrlog that are over 90 days old ? I tried the "find" cmd, but it shows current files also. The "file" cmd indicates these are "data" files.

*******************************************
root[/auditlog/usrlog]
# find /auditlog/usrlog -type f -mtime +90 -exec ll \; | more

Mar 14 2004 c4c6669.3142004.a09940
-rw------- 1 root root 2272 Mar 26 2004 c4c6669.3262004.a06653
-rw------- 1 root root 4086 May 16 2004 c4c6669.5162004.a03889
-rw------- 1 root root 2983 Apr 20 12:40 j4s9389.4202005.a09390
-rw------- 1 root root 2986 Apr 21 07:18 j4s9389.4212005.a23144
-rw------- 1 root root 3280 Apr 21 07:34 j4s9389.4212005.a23186
***********************************

# file j4s9389.4212005.a23144
j4s9389.4212005.a23144: data


6 REPLIES 6
Rick Garland
Honored Contributor

Re: find cmd to search for files older than 90 days

Use print instead of exec ll.

find . -type f -mtime +90 -print
RAC_1
Honored Contributor
Solution

Re: find cmd to search for files older than 90 days

touch -ct "file_with_90day_back_time"

find /dir -type f !-newer "file_with_90day_back_time" -exec ll -d {} \;

Anil
There is no substitute to HARDWORK
Pete Randall
Outstanding Contributor

Re: find cmd to search for files older than 90 days

I think it might be your syntax. Try
find /auditlog/usrlog -type f -mtime +90 -exec ll {} \;


Pete

Pete
Rick Garland
Honored Contributor

Re: find cmd to search for files older than 90 days

Can do it with both print and exec.

find /auditlog/usrlog -type f -mtime +90 -print -exec ll {} \;

Jeff Schussele
Honored Contributor

Re: find cmd to search for files older than 90 days

Hi Jerry,

Besides what Rick points out you also need an operator and an expression - like:

find . \( -type f -a -mtime +90 \) -print

Note that the parens need to be escaped & the -a is an and operator.

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

Re: find cmd to search for files older than 90 days

Hi Jerry,


Here is a user friendly script.

###########################################################
#This script finds recenty created large files
#
#Syamkumar
#TCSL
#26/01/2004
#
#
rm -f find.out

echo
echo "Enter directory to search"
read DIRNAME

if [ ! -d $DIRNAME ]
then
echo "Error: directory $DIRNAME does not exist"
exit 1
fi

echo
echo "How large a file do you want to look for ? (in Kbytes)"
read SIZE

echo
echo "How many days since the file was created ?"
read DAYS

echo
echo "Searching..."

find $DIRNAME -type f -size +$SIZE -mtime -$DAYS -exec ls -ls {} \; | sort -n -r | tee find.out

echo
echo "Done"
echo
echo "Note: output in find.out"
echo

########################################################

Regards,
Syam