This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new 49f2ec4  Script to purge old files
49f2ec4 is described below

commit 49f2ec47558be7d283b2698ec53a9b6695ddd86b
Author: Sebb <[email protected]>
AuthorDate: Wed May 1 21:37:12 2019 +0100

    Script to purge old files
---
 tools/monthly_tidy.rb | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/tools/monthly_tidy.rb b/tools/monthly_tidy.rb
new file mode 100644
index 0000000..7bb2c8c
--- /dev/null
+++ b/tools/monthly_tidy.rb
@@ -0,0 +1,23 @@
+#!/usr/bin/env ruby
+
+# @(#) monthly tidy-up script
+
+# Script to tidy up directories
+#
+# Deletes files older than 13 months from the following directories:
+# - /srv/mail/board
+# - /srv/mail/members
+
+require 'date'
+require 'fileutils'
+
+keep = (Date.today << 13).strftime('%Y%m')
+
+MAIL = '/srv/mail'
+
+Dir["#{MAIL}/board/20*", "#{MAIL}/members/20*"].each do |dir|
+  if File.basename(dir) < keep
+    puts "Deleting #{dir}"
+    FileUtils.rm_rf dir
+  end
+end

Reply via email to