delete files older XY days

Hermann S 6 years ago updated 4 years ago 6

when i delete files with a cron job e.g. older 30 days, i have to use a bash script with some SQL statements to remove this files also from the database.

it would be nice, if an admin or super admin account has the ability to configure a value when files will be deleted automatically, globally or user specified.


Thank you for the feature request! We will add a FileRun command line script for deleting older files, so that you don't have to maintain your custom one. Then you will be able to add that to your cron job.

P.S. It's unlikely that we will add a web-based option inside FileRun, as that creates the risk of accidental file loss and it also won't be efficient to run such process through the web server, as its execution time would be limited.


The feature will be available with the upcoming update.

How do I create the CronJob to auto delete files over XY days old?

Tried to follow the cron job instructions, with the /path/to/directory/* -mtime +t -exec rm {} \;

1. The .txt. file goes into the home/bin folder correct?

2. I have contracts that are also in a sub folders for each of my clients, for record and archive. Lets say the only files I want to delete over 60 days old are .mp3 and .wav files. Everything else must stay intact regardless of time frame.

What command will accomplish this?

I use cPanel and my server is Linux


Would this work if saved to a PHP file called find-and-delete-audio.php



rm -rf ~/public_html/audio/*{.wav,.mp3}

// ...


The the command line for the cron job:

118*** php find-and-delete-audio.php --days 45