Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2008
    Posts
    14

    Unanswered: Deleting files that are older than 5 days

    Hi All,

    Can you please let me know how to delete files in ksh that are older than 5 days

    find <dir> -type f -mtime +5 -exec rm -f {} \;

    I executed the above today it deletes the files created on 28th and not the files created on 30th.

    Thanks in advance for your responses.

    Regards,
    P_db_user

  2. #2
    Join Date
    Jul 2008
    Posts
    14
    The below is what I tried.

    find . -type f \( -ctime +3 -o -ctime 3 \) -exec rm -f {} \;

    If it is not correct can you please correct me

    Regards,
    P_db_user
    Last edited by P_db_user; 11-06-08 at 00:34.

  3. #3
    Join Date
    May 2005
    Location
    South Africa
    Posts
    1,365
    Provided Answers: 1
    man find
    Code:
         ...
         Example 6: Selecting a File Using 24-hour Mode
    
         The descriptions of -atime, -ctime, and -mtime use the  ter-
         minology n "24-hour periods''. For example, a file accessed
         at 23:59 is selected by:
    
         example% find . -atime -1 print
    
         at 00:01 the next day (less than 24 hours  later,  not  more
         than one day ago). The midnight boundary between days has no
         effect on the 24-hour calculation.
         ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •