summaryrefslogtreecommitdiffstats
path: root/examples/VFS/recycle/cleanup_recycle.pl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/VFS/recycle/cleanup_recycle.pl')
-rw-r--r--examples/VFS/recycle/cleanup_recycle.pl25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/VFS/recycle/cleanup_recycle.pl b/examples/VFS/recycle/cleanup_recycle.pl
new file mode 100644
index 00000000000..f614cf78708
--- /dev/null
+++ b/examples/VFS/recycle/cleanup_recycle.pl
@@ -0,0 +1,25 @@
+# !/usr/bin/perl -w
+#
+# this script looks for all files with an access date older than
+# $maxage days and deletes them.
+# Empty directories will be deleted afterwards
+#
+
+$dirpath = "/data/.recycle";
+$maxage = 2;
+
+# delete all old files
+@a=`find $dirpath -atime +$maxage`;
+foreach (@a)
+ {
+ print "deleting file: $_";
+ $r = `rm -f $_ 2> /dev/zero`;
+ }
+
+# delete all empty directories
+@a=`find $dirpath -type d | sort -r`;
+foreach (@a)
+ {
+ print "deleting directory: $_";
+ $r = `rmdir $_ 2> /dev/zero`;
+ }