FG
💻 Software

Delete all files older than X days

Fresh5 days ago
Mar 15, 20263095 views
Confidence Score0%
0%

Problem

So I have a cron setup to make backups of a folder into a tarball every hour. I would like to add into the shell script that I'm using the ability to have files deleted automagically after about three days, so that I don't have a crap ton of files. How can I go about this? Thanks.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: Delete all files older than X days

Low Risk

Add this line to the script (modify accordingly): This assumes your backup tarballs and only your backup tarballs reside in that folder. You could also use the utility:

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment