Delete files older than 'x'

Run Settings
LanguageBash
Language Version
Run Command
################################################################################################### # Finds <indicated files or filetypes> OLDER THAN 45 days inside the backup dir and deletes them # ################################################################################################### # Modified from https://www.howtogeek.com/howto/ubuntu/delete-files-older-than-x-days-on-linux/ # !!!!!!!!!!!!! # To check which files will be removed, DO NOT use anything past '+45' # !!!!!!!!!!!! #||#||#||#||# To check which files will be KEPT swap the + for a -, and DO NOT ADD '-exec rm {} \;'. #||#||#||#||# find /var/atlassian/application-data/confluence/backups/* -mtime +45 -exec rm {} \; #### finding all .sql files older than 45 days find /srv/ansible_managed_backups/*.sql -mtime +45 #### finding all .zip files older than 45 days find /srv/ansible_managed_backups/*.zip -mtime +45 ##### To find all files with the extension `.tar.gz`, that are OLDER than 45 days and also return TOTAL sizes: find /srv/ansible_managed_backups/*.tar.gz -mtime +45 | xargs du -hcs ##### To find files with name starting with <indicated below>, that are OLDER than 45 days and also return TOTAL sizes: find /srv/ansible_managed_backups/iris_jira_home_dir* -maxdepth 0 -type d -mtime +45 | xargs du -hcs ##### To find ONLY directories with name starting with <indicated below>, that are OLDER than 45 days and also return TOTAL sizes: find /srv/ansible_managed_backups/iris_jira_home_dir* -type d -mtime +45 | xargs du -hcs ##### To find ONLY directories with the name starting with <indicated below>, that are OLDER than 45 days ##### limiting the depth of output to the directory itself with no depth: find /srv/ansible_managed_backups/iris_jira_home_dir* -maxdepth 0 -type d -mtime +45 ######## To DELETE ONLY directories with the name starting with <indicated below>, that are OLDER than 45 days ######## limiting the depth of this removal to the directories themselves: find /srv/ansible_managed_backups/iris_jira_home_dir* -maxdepth 0 -type d -mtime +45 -exec rm {} \;
Editor Settings
Theme
Key bindings
Full width
Lines