Skip to content

Instantly share code, notes, and snippets.

@slyness
Created October 8, 2014 21:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slyness/03d55a74dcb6afdb71c6 to your computer and use it in GitHub Desktop.
Save slyness/03d55a74dcb6afdb71c6 to your computer and use it in GitHub Desktop.
# Clean up open-uri files in /tmp 3 days old or older
# three days = 259200 seconds = 60 * 60 * 24 * 3
THREEDAYS = 259200
files = []
files = ::Dir["/tmp/open-uri*"]
files.each do |f|
shackserv_owned = ::File.stat(f).uid == 5001
aged_file = Time.now.to_i - ::File.stat(f).mtime.to_i >= THREEDAYS
if ( shackserv_owned && aged_file )
file f do
action :delete
backup false
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment