Delete Old Files Automatically
Explanation 🔗
Source: https://stackoverflow.com/questions/45838304/bash-delete-files-older-than-3-months
Before you actually run the delete command it might be good to use -print
as below to see what will be deleted.
In both commands (the print and delete one):
PATH
should be replaced with the path to the folder you want to do the deletes in.DAYS
should be replaced with the number of days you need.
See also cron for automating the command
Preview output via print 🔗
find PATH -mtime DAYS -type f -print
Actual delete command 🔗
find PATH -mtime DAYS -type f -delete