Hello, together
Since last month I work with Ruby.
I realised that I leave in the work often log files which are older than
1 month.
Now I want to delete them, however, a ruby script would be more sensible
there.
I know, I can do that in shell, but I want it in ruby.
Can someone send me a example script who does that?
Greetings
rubyamateur
Ruby Amateur wrote in post #1185726:
Hello, together
Since last month I work with Ruby.
I realised that I leave in the work often log files which are older than
1 month.
Now I want to delete them, however, a ruby script would be more sensible
there.
last_month= Date.today << 1
Dir.glob("*.log").select {|f|
File.mtime(f).to_date < last_month
}.each {|f|
File.delete(f)
}