Find and Remove old files
This blog has been moved to http://geekaider.com
Find command usage:
find <where> <condition>find /backup/daily -name log.*find <where> <condition> -exec <action>
find /backup/daily -name log.* -exec ls -l {} \;Find log files older than 2 days in /backup/daily directory
find /backup/daily/log.* -mtime +2
Find log files older than 2 days(modified 2 days back) in /backup/daily directory and remove them
find /backup/daily/log.* -mtime +2 -exec rm {} \;
NOTE: -exec <space> rm <space> {} <space> \;
Find log files older than 12 hours in /backup/daily directory and remove them
find /backup/daily/log.* -mmin +12 -exec rm {} \;
Find log files newer than 2 hours in /backup/daily directory and remove them
find /backup/daily/log.* -mmin -120 -exec rm {} \;
No comments:
Post a Comment