Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
rb:deleteoldfiles [10/10/2013 14:21]
127.0.0.1 external edit
rb:deleteoldfiles [03/10/2014 08:50] (current)
andrew
Line 1: Line 1:
 ====== Delete files older than X days ====== ====== Delete files older than X days ======
-  
  
 +Version 1
 +
 +<code bash> ​
 +#!/bin/bash
 +#Written Andrew Stringer
 +#This is to find old files and purge them to prevent backups filling
 +#the system up.
 +
 +#Backup files stored to here:-
 +BASEDIR='/​mnt/​datastore/​db-backup'​
 +
 +echo "​Starting run at `date`"​ > ${BASEDIR}/​housekeeping.log
 +
 +#find files older than 2 days & delete them
 +rm -rf `find ${BASEDIR} -type d -mtime +1` >> ${BASEDIR}/​housekeeping.log
 +
 +exit 0
 +</​code>​
 +
 +Version 2
  
   #!/bin/bash   #!/bin/bash

rb/deleteoldfiles.txt ยท Last modified: 03/10/2014 08:50 by andrew