Results 1 to 4 of 4

Thread: rm files older than two days

  1. #1
    Join Date
    May 2009
    Posts
    2,105

    rm files older than two days

    Can some one show me a shell script to remove files older than yesterday. I mean, today its 23rd June and i need to delete the files that are older than 21st June. How can i do that ? Please help me.

  2. #2
    Join Date
    Apr 2008
    Posts
    2,139

    Re: rm files older than two days

    Its very simple. Here it is :-

    find /path/to/dir -type f -mtime +3 -exec rm \{\} \



    To find a file that, but less than 24 hours ago yesterday was amended, try this:
    find . \! -cnewer date_marker


    To find files created before that date, use the cnewer and negation conditions:
    find . -newer date_marker

    The day starts at the actual beginning of the day, not 24 hours ago.
    find . -daystart -atime 1 -maxdepth

  3. #3
    Join Date
    Feb 2009
    Posts
    192

    Re: rm files older than two days

    Its $ find /path/to/folder -mtime +3 -exec rm -f {} \;,Where the first argument the path to the files. This can be a way or a folder.The second argument, -mtime, is used to specify the number of days old that the file is. If you enter +5, it will find files older than 5 days.The third argument - exec, allows you to enter a command such as rm so. () \; At the end is required for command to terminate.

  4. #4
    Join Date
    May 2009
    Posts
    2,105

    Re: rm files older than two days

    Thanks a lot guys,,, that is all what i needed .I appreciate your quick help.

    Thank You!!

Similar Threads

  1. Replies: 4
    Last Post: 29-05-2013, 10:19 AM
  2. Replies: 5
    Last Post: 15-02-2012, 02:58 AM
  3. Replies: 6
    Last Post: 10-08-2010, 04:14 PM
  4. delete files older than...
    By Hugo in forum Windows Server Help
    Replies: 5
    Last Post: 21-05-2010, 03:18 PM
  5. Looking for a script to delete files older than 14 days
    By Michael Kapangama in forum Windows Server Help
    Replies: 3
    Last Post: 27-09-2008, 03:56 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,727,376,453.31463 seconds with 17 queries