Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell script to delete files older than 30 days 1

Status
Not open for further replies.

ady2k

Vendor
Jan 28, 2002
463
ID

I would like delete log files older than 30 days and use crontab to do it.
Any shell script expert can provide delete files older than 30 days script to me?
Thanks for advance....:)
 
The log files generated by oracle application.
I can't use logrotate.
Thanks
 
man find.

One of the options can find those files, and then you -exec rm {}.

exec is also an option, and there probably be an example in the man page to do what you want.
 
This will delete files (by extension) older than 30 days.
Code:
# Remove files that are older than 30 days
0 1 * * * find /your/file/dir/*.ext -atime +30 -print | xargs rm

M. Brooks
X Concepts LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top