Script for removing old files

Associate
Joined
19 Jul 2006
Posts
1,847
Why does'nt this work?

Code:
#/bin/sh
BACKUP_DIR="/backups"
DAYS_TO_RETAIN=10
find $BACKUP_DIR -maxdepth 1 -type f -ctime +$DAYS_TO_RETAIN -delete

Im using openSuse.
I have 3 directiories that I want to empty so theres no files older than 10 days in there
/backups/moodlesoftwere/moodlesoftwere/2009/Feb
/backups/mysql_backups/moodle/2009/Feb
/backups/moodledata/moodledata/2009/Feb

TIA
 
Thanks all.
That explanation is brilliant inph, as im still learning linux. I changed the -maxdepth to 5 but i may get rid of it.

the ctime worked but i take on board the mtime comment
 
Back
Top Bottom