Operating System - HP-UX
1834530 Members
3213 Online
110068 Solutions
New Discussion

To find files which have not been modified (accessed) in the last 10 days

 
SOLVED
Go to solution
Bedare Nikhil
Advisor

To find files which have not been modified (accessed) in the last 10 days

Hi,

How can we find the files which have not been modified or accessed for the last 10 days ?
Is there any specific command to do this ?
4 REPLIES 4
spex
Honored Contributor
Solution

Re: To find files which have not been modified (accessed) in the last 10 days

Hi Bedare,

Files which have not been modified in the last 10 days:
$ find /path -type f -mtime +10 -print

Files which have not been accessed in the last 10 days:
$ find /path -type f -atime +10 -print

$ man 1 find
for more information.

PCS
gstonian
Trusted Contributor

Re: To find files which have not been modified (accessed) in the last 10 days

We use the following to find and remove older files from certain areas. Change the rm -r to anything you like (i.e. ll etc)


/usr/bin/find /tmp -type f -mtime +5 -exec rm -r {} \;
/usr/bin/find /var/tmp -type f -mtime +5 -exec rm -r {} \;

Berd
Trusted Contributor

Re: To find files which have not been modified (accessed) in the last 10 days

Hi Bedare,

You need to use the find command. There are two flags to consider, -atime and -mtime. The first lets you find based on access time and the latter on modify time. So you need to decide which you want to use.

We use the below to remove log files

find /log_directory -name logfile.* -atime +10 -exec {} \;

HTH

Berd
Dennis Handly
Acclaimed Contributor

Re: To find files which have not been modified (accessed) in the last 10 days

>Berd: find /log_directory -name logfile.* -atime +10 -exec {} \;

This is missing "rm". It also should be changed to use the "+" syntax for performance:
find /log_directory -name "logfile.*" -atime +10 -exec rm -f +