Monday, January 7, 2013

USEFUL COMMAND RELATED TO OLDER FILE

Usually, it is very boring to do monitoring or housekeeping of file one by one. 
Below is example command that maybe useful.

1) I want to find oracle archive log files that older than 2 day
    # find /oracle/ABC/oraarch -name "*.dbf" -mtime +2 -exec ls -l {} \;

2) I want to move oracle archive log files that older than 3 day to dummy folder
    # find /oracle/ABC/oraarch -name "*.dbf" -mtime +3 -exec mv {} /dummy/;
 
3) I want to zip oracle archive log files that older than 4 day
    # find /oracle/ABC/oraarch -name "*.dbf" -mtime +4 -exec gzip {} \;

4) I want to remove oracle archive log files that older than 5 day
    # find /oracle/ABC/oraarch -name "*.dbf" -mtime +5 -exec rm {} \;

5) I want to delete 150 oracle archive log oldest files 
    # rm -f  `ls -tr /oracle/ABC/oraarch/*.dbf | head -150`







No comments:

Post a Comment