3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rubyで特定のディレクトリ配下で○日以上古いファイルを削除する

Posted at

ActiveSupport1.dayを使うためだけに読み込んでます。

.rb
require 'active_support'
require 'active_support/core_ext'
Dir.glob('/var/foo/**/*.yml').
select{|f| File.mtime(f) < Time.now - 1.day }.
each{|f| FileUtils.rm(f)}

参考

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?