The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Deleting files by date

Discussion in 'General Discussion' started by Marty, Apr 23, 2005.

  1. Marty

    Marty Well-Known Member

    Joined:
    Oct 10, 2001
    Messages:
    630
    Likes Received:
    1
    Trophy Points:
    18
    Can someone give me the SSH command to delete all the files in a directory that are older than two years?

    Thanks
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    This should do it:

    find /<path to directory>/ -mtime +730 | xargs rm -fv

    However, I'd suggest you try it like this first:

    find /<path to directory>/ -mtime +730 | xargs ls -la
     
Loading...

Share This Page