How can I delete all files that are older than one year from a certain directory within the bash?
Thanks!
|
feedback
|
The only 2 commands used are find and rm. Find looks for files (-type f), this to exclude directories, that are older then 3 days (-mtime +3). All it finds is given to rm (-exec rm {} \; ). You could also place the rm statement outside of find, which is supposed to be faster: find /u1/database/prod/arch -type f -mtime +3 | xargs rm | |||||||||||
feedback
|
|
another approach I found. nice for specific dates.
| |||
|
feedback
|
|
tmpwatch does a good job, example:
Exerpt from manual:
| |||
|
feedback
|
|
tmpwatcher or "tmpreaper" in ubuntu. http://linux.about.com/library/cmd/blcmdl8_tmpwatch.htm use with -c | |||
|
feedback
|