Delete files older than 4 months old

Posted on 2010-01-05
Last Modified: 2012-06-27
I have a folder with thousands of sub-folders and files and I'm wanting to delete all the files and folders older than 4 months.

Is there an SSH command I can issue that would do this?
Question by:PeterErhard
    LVL 17

    Accepted Solution

    you should be able to find a couple of example here:

    good luck
    LVL 84

    Assisted Solution

    find /folder -mtime +120  -exec rm {} \;
    LVL 68

    Assisted Solution

    use "find" with its "-mtime" "option. Additionally use the "-depth" option to have find process the contents of a folder before the folder itself.
    find /folder -depth -mtime +120 | xargs -I{} rm -r {}
    To run it on a remote server using ssh simply do
    ssh user@host  "find /folder -depth -mtime +120 | xargs -I{} rm -r {}"

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now