Purchase Linux CDs / DVDs / Flash Drives at OSDisc.com

Welcome to Our Community

While Linux.org has been around for a while, we recently changed management and had to purge most of the content (including users). If you signed up before April 23rd please sign up again. Thanks!

Remove files older than X

Discussion in 'Command Line' started by Rob, Oct 28, 2011.

  1. Rob

    Rob Guest

    We have video cameras saving footage on to a fileserver - but it's taking up about 30G/day.. so I wanted to do something to remove files older than a week or so.. All it took was throwing this command into a cron job:




    Code:
    /usr/bin/find /mnt/data/cam/201?/ -type f -mtime +8 -exec rm -f {} \;
    

    This will find files under the /mnt/data/cam/2011/ (or 2012, 2013, etc..) directory that are 8 days old and remove them. You can test the command by replacing "rm -f" with "ls" to see what files it found..
     
  2. Gerad

    Gerad Guest

    If you just want to find a list of files that is older than 90 days. I find that this command works pretty well.

    Code:
    find . -name "*" -mtime -90 -print 
     
    1 person likes this.
  3. bashcommando

    bashcommando Guest

    There goes X10
     

Share This Page