假設要移除七天前的檔案

find /workdir/logs -type f -mtime +7d | xargs rm -rf {}

定時執行的話,加入crontab即可

     -mtime n[smhdw]
             If no units are specified, this primary evaluates to true if the
             difference between the file last modification time and the time
             find was started, rounded up to the next full 24-hour period, is
             n 24-hour periods.

             If units are specified, this primary evaluates to true if the
             difference between the file last modification time and the time
             find was started is exactly n units.  Please refer to the -atime
             primary description for information on supported time units.


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 helloworld 的頭像
    helloworld

    Hello World

    helloworld 發表在 痞客邦 留言(0) 人氣()