Operating System - HP-UX
1826123 Members
4906 Online
109690 Solutions
New Discussion

Shell script that count 90 day!!!

 
SOLVED
Go to solution
gigiz
Valued Contributor

Shell script that count 90 day!!!

Hi,
i need to cancel by script in a directory a file oldest than 90 day .
Help me Thanks a lot .....
6 REPLIES 6
Pete Randall
Outstanding Contributor
Solution

Re: Shell script that count 90 day!!!

find /dirname -type f -mtime +90 -exec rm {} \;


Pete

Pete
Ivan Ferreira
Honored Contributor

Re: Shell script that count 90 day!!!

Hi gigiz, the command above is perfect, but just be carefull when you specify the mtime value, if you do a mistake and instead of +90 you specify -90, you will delete all files that where created in the last 90 days.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
James R. Ferguson
Acclaimed Contributor

Re: Shell script that count 90 day!!!

Hi:

If your directory has potentially a large number of candiates for removal, it is far more efficient to use 'xargs' in lieu of '-exec' to buffer many file name arguments into one 'rm' process:

# find /path -xdev -type f -mtime +90 | xargs rm

Regards!

...JRf...
Nguyen Anh Tien
Honored Contributor

Re: Shell script that count 90 day!!!

Hi Gigiz
I see the command pete given to you is the best!
#find /dirname -type f -mtime +90 -exec rm {} \;

tienna
HP is simple
Arturo Galbiati
Esteemed Contributor

Re: Shell script that count 90 day!!!

Hi

find start_directory -type f -mtime +90 -exec rm {} \;

HTH,
Art
gigiz
Valued Contributor

Re: Shell script that count 90 day!!!

OK!!!!