Delete Old Files Automatically

Chester Wyke February 28, 2025 Updated: April 26, 2025 #Debian

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):

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