Delete files older than 30 days

1. Save the deleted files to a log file

This way, you’ll get a line at top with the date the line is executed (also a line at the bottom).
The last two semicolons are necessary, one is for find and one for bash.

2. modified

Find and delete files modified in the last 30 minutes

mtime = days
mmin = minutes

3. force

force delete temp files older then 30 days

4. move the files

move files older than 30 days to an archive folder – and preserve path strcuture

mv -t: ensure directory structure is preserved


1. Source of Tips:
2. Using the find command to find Files by date: unix-find-newest-files-and-files-by-timestamp
3. man find
4. man mv
5. Find Files By Age and Timestamp: /2383/unix-find-files-by-age-and-timestamp

About Gugulethu Ncube

IT enthusiast getting things done.