Forum: Ruby Script which deletes and comprisses logfiles

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ruby A. (Guest)
on 2017-03-22 10:54
Hello, together
Since last month I work with Ruby.
I realised that I leave in the work often log files which are older than
3 months.
Now I want to delete them, however, a script would be more sensible

Can somebody show me how do I write a script which compresses my old log
files (older than 3 months) and delete them also?

Ronald F. (Guest)
on 2017-03-22 15:32
I wonder why you want to do it in Ruby, because this is such a typical
shell script task: Use 'find' for locating the old files, 'zip' to
compress them, and 'rm' to remove the unused ones.

Of course, you can do it in Ruby too:

The Ruby equivalent to find is the class Find,

Compressing is done by Zlib,

I don't think deleting a file will cause you problems....
This topic is locked and can not be replied to.