Operating System - HP-UX
1835989 Members
4820 Online
110088 Solutions
New Discussion

Tidy up of files in a directory

 
SOLVED
Go to solution
Nick D'Angelo
Super Advisor

Tidy up of files in a directory

All,

I am having strange difficulties with the removal of some files.

I am trying to remove all files in a directory older than 120 days (6 months).

I have tried the following commands to no avail: (I have put the full line in quotes so that it would appear on this posting only.

cd /dirname
"find . -atime +120 -exec rm {} \;"
"find . -name "sapconf.*" -atime +120 -exec rm {} \;"

The syntax is correct I believe as it is not returning an error message.

For some reason it is not picking up my file list.

The directory looks like this and as you can see, I have some files that are older than 6 months.
total 3958
-rw-rw-rw- 1 pics users 111 May 27 1999 sapconf.99052764004
-rw-rw-rw- 1 pics users 204 Jun 18 1999 sapconf.99061864239
-rw-rw-rw- 1 pics users 146 Jun 18 1999 sapconf.99061865142
-rw-rw-rw- 1 pics users 527 Jun 21 1999 sapconf.99062135964
-rw-rw-rw- 1 pics users 567 Jun 21 1999 sapconf.99062136333
-rw-rw-rw- 1 pics users 713 Jun 22 1999 sapconf.99062251597
-rw-rw-rw- 1 pics users 5836 Jul 15 1999 sapconf.99071555807
-rw-rw-rw- 1 pics users 8024 Jul 22 1999 sapconf.99072246054
-rw-rw-rw- 1 pics users 2901 Jul 22 1999 sapconf.99072246351
-rw-rw-rw- 1 pics users 4164 Aug 27 1999 sapconf.99082753823
-rw-rw-rw- 1 pics users 2769 Aug 27 1999 sapconf.99082761942
-rw-rw-rw- 1 pics users 2862 Aug 27 1999 sapconf.99082762759
-rw-rw-rw- 1 pics users 220 Sep 16 1999 sapconf.99091641099
-rw-rw-rw- 1 pics users 2106 Nov 2 1999 sapconf.99110239129
-rw-r--r-- 1 root sys 11065 May 23 2000 sapconf.00052371491
-rw-rw-rw- 1 pics users 109 May 24 2000 sapconf.00052041687
-rw-r--r-- 1 root sys 13173 May 24 2000 sapconf.00052470617
-rw-r--r-- 1 root sys 11986 May 25 2000 sapconf.00052570723
-rw-r--r-- 1 root sys 2396 May 26 2000 sapconf.00052670376
-rw-r--r-- 1 root sys 0 May 27 2000 sapconf.00052768578
-rw-r--r-- 1 root sys 0 May 29 2000 sapconf.00052970372
-rw-r--r-- 1 root sys 10856 May 30 2000 sapconf.00053070377
-rw-r--r-- 1 pics users 9568 May 31 2000 sapconf.00052270616
-rw-r--r-- 1 root sys 16731 May 31 2000 sapconf.00053170377
-rw-r--r-- 1 root sys 6931 Jun 1 2000 sapconf.00060170366
#
Suggestions/ideas would be greatly appreciated.
Nickd
Always learning
3 REPLIES 3

Re: Tidy up of files in a directory

Don't quote me on this (haven't got man pages to hand) but shouldn'y you be using -mtime rather than -atime?

I am an HPE Employee
Accept or Kudo
James R. Ferguson
Acclaimed Contributor
Solution

Re: Tidy up of files in a directory

Nick:

Duncan is indeed correct. If you want to find files based on modification date, use 'mtime'. For searches based on last-access date, use 'atime'. For searches based on the last inode change (permissions modified, file moved, etc.) use 'ctime'. For the 'n' argument. '+n' means more than 'n', '-n' means less than 'n', and 'n' means exactly 'n'.

Thus, in your case, you looked for files that were not accessed during the last 120-days.

...JRF...
Nick D'Angelo
Super Advisor

Re: Tidy up of files in a directory

Thank you to both of you.

This forum is extremely helpful to people like me who work at a company where there is no other Unix Knowledgable people. Not even the 25% that I know ;-)

Sometimes, you can not see the trees for the forest.

Thanks again.
Always learning