|
|
Question : Removing old files
|
|
How do I remove files that were created 1 minute ago, yesterday, and 7 days ago
option mmin does not work for $ find /iaprod/bin/sfatr/pdma_qa_logs -type f -mmin +10 -print find: bad option -mmin find: path-list predicate-list
I am using SUNOS
|
Answer : Removing old files
|
|
To remove files older than 1 minute, do:
touch -t `perl -MPOSIX -e 'print strftime "%Y%m%d%H%M", localtime(time-60)'` /tmp/ref find /some/dir ! -newer /tmp/ref -exec rm -f {} \;
For yesterday it depends if you mean 24 hours ago or based on midnight. It's easy for 1 day or 7 days, you just do
find /some/dir -mtime +0 -exec rm -f {} \; find /some/dir -mtime +6 -exec rm -f {} \;
|
|
|
|
|