07 Jan

Commands to delete files older than X days

Delete files older than X days

To delete files older than X days, please execute the below commands. The below commands will remove files from a specific folder location in your machine\server. If you want to change the day, then just change value of 90 with your value,

1
find /directory/path/to/your/file -mindepth 1 -mtime +90 -delete

or

1
find /directory/path/to/your/file -type f -mtime +90 -exec rm {} \;

or

1
find /directory/path/to/your/file -mindepth 1 -type f -mtime +90 | xargs rm

Before executing the script,

delete files older than X days

After executing the script

delete files older than X days

 

Leave a Reply

Your email address will not be published. Required fields are marked *

6 + 19 =