Comments on: How to Delete Files Older than 30 days in Linux https://tecadmin.net/delete-files-older-x-days/ How to guide for System Administrator's and Developers Sat, 06 Aug 2022 11:39:38 +0000 hourly 1 https://wordpress.org/?v=6.1.1 By: Anoop https://tecadmin.net/delete-files-older-x-days/#comment-63401 Mon, 27 Sep 2021 00:39:39 +0000 https://tecadmin.net/?p=2450#comment-63401 find /home/*/* -name “*.tar.gz” -type f -mtime +30 -exec rm -rf {} \;

is there any way to exclude one folder and its files on above command

]]>
By: Tobias Heel https://tecadmin.net/delete-files-older-x-days/#comment-62767 Tue, 06 Apr 2021 14:35:08 +0000 https://tecadmin.net/?p=2450#comment-62767 I get the same error.

Command:
find /volume1/DeleteOldBackUps_TEST/Dest_Old/test-02/ -type f -mtime +31 -exec rm {} \;

]]>
By: mamadou https://tecadmin.net/delete-files-older-x-days/#comment-57854 Wed, 20 Jan 2021 11:47:56 +0000 https://tecadmin.net/?p=2450#comment-57854 find /mnt/backup/backup -name “*.x.tar.gz” -type f -mtime “+$(( ( $(date ‘+%s’) – $(date -d ‘2 months ago’ ‘+%s’) ) / 86400 ))”
Returns errors:
date: invalid date ‘‘+%s\’’
date: extra operand ‘ago\’’

Any idea?

]]>
By: Walter https://tecadmin.net/delete-files-older-x-days/#comment-57403 Mon, 04 Jan 2021 13:24:14 +0000 https://tecadmin.net/?p=2450#comment-57403 #!/bin/bash

find /mnt/backup/backup -name “*.x.tar.gz” -type f -mtime “+$(( ( $(date ‘+%s’) – $(date -d ‘2 months ago’ ‘+%s’) ) / 86400 ))” -exec rm -f {} \;

#Use crontab to schedule as required

]]>
By: Antonio https://tecadmin.net/delete-files-older-x-days/#comment-55257 Wed, 21 Oct 2020 03:20:29 +0000 https://tecadmin.net/?p=2450#comment-55257 How do I write a script and scheduled to run monthly to delete backup files (x.tar.gz) 2-months old on located on /snap folder in a Red Hat Linux server?

]]>
By: Antonio Reyes https://tecadmin.net/delete-files-older-x-days/#comment-55256 Wed, 21 Oct 2020 03:18:06 +0000 https://tecadmin.net/?p=2450#comment-55256 How do I write a script and scheduled to run monthly to delete backup files (x.tar.gz) on /snap folder in a Red Hat Linux server?

]]>
By: Dave https://tecadmin.net/delete-files-older-x-days/#comment-55181 Thu, 15 Oct 2020 10:08:30 +0000 https://tecadmin.net/?p=2450#comment-55181 could just add the -delete flag rather than piping to rm

]]>
By: Junior_mahatma https://tecadmin.net/delete-files-older-x-days/#comment-52673 Fri, 24 Jul 2020 08:46:21 +0000 https://tecadmin.net/?p=2450#comment-52673 This only removes the files. What if you have a sub folders and you also want to delete these. What do you do then ?

]]>
By: JR https://tecadmin.net/delete-files-older-x-days/#comment-43473 Thu, 31 Oct 2019 01:22:53 +0000 https://tecadmin.net/?p=2450#comment-43473 How to delete files/folders from a directory older than a certain date?
Ex:- Delete all files and folders from a specified path older than 01-Jan-2018

]]>
By: Lakshmi https://tecadmin.net/delete-files-older-x-days/#comment-43271 Fri, 18 Oct 2019 07:30:19 +0000 https://tecadmin.net/?p=2450#comment-43271 How to find and delete files older than 90 days in linux?

]]>