0
Completed

delete files older XY days

Hermann S 5 years ago updated 2 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.


+1
Planned

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.

Completed

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


Dave

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


#!/usr/local/bin/php

<?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