How to remove files Older Then “n” days

This command will remove all files which older than 365 days.  Be careful when you need to run this command. Before add "rm" use "ls"  option to see that  files..

  • List all files older than 365 days.
#find /pathtofile -type f -mtime +365 -prune | xargs ls  -ld

For  Linux  also;

#find /tmp -atime +365
  • Remove all files older than 365 days.
#find /pathtofile -type f -mtime +365 -prune | xargs rm –r 


I'm a IT Infrastructure and Operations Architect with extensive experience and administration skills and works for Turk Telekom. I provide hardware and software support for the IT Infrastructure and Operations tasks.

205 Total Posts
Follow Me

Related Post