Jul 2, 2002 #1 newhandle Technical User Aug 28, 2001 2 AU What is the command to delete files older than 5 days ? Thanks.
Jul 3, 2002 #2 KenCunningham Technical User Mar 20, 2001 8,475 GB Hi newhandle, you can use find for this: find <directory to delete from> -mtime +5 -exec rm {} \; Be careful with this - it deletes everything not modified for 5 days or more in the specified directory. It's always as well to do a: find <directory to delete from> -mtime +5 -print first, just to check that the files returned are indeed the ones you want. If not, it's possible the specify certain files like: find <directory to delete from> -name '*.txt' -mtime +5 -exec rm {} \; Replace *.txt with whatever filename/extension combination you require. Hope this helps. Upvote 0 Downvote
Hi newhandle, you can use find for this: find <directory to delete from> -mtime +5 -exec rm {} \; Be careful with this - it deletes everything not modified for 5 days or more in the specified directory. It's always as well to do a: find <directory to delete from> -mtime +5 -print first, just to check that the files returned are indeed the ones you want. If not, it's possible the specify certain files like: find <directory to delete from> -name '*.txt' -mtime +5 -exec rm {} \; Replace *.txt with whatever filename/extension combination you require. Hope this helps.
Jul 3, 2002 #3 mrn MIS Apr 27, 2001 3,993 GB You also have the -atime & -ctime options atime = access time ctime = inode updated during the last 24 hrs Regards -- | Mike Nixon | Unix Admin | http://www.instantflashshop.com---------------------------- Upvote 0 Downvote
You also have the -atime & -ctime options atime = access time ctime = inode updated during the last 24 hrs Regards -- | Mike Nixon | Unix Admin | http://www.instantflashshop.com----------------------------