Created
February 13, 2022 16:39
-
-
Save ramiroencinas/c871f8ab65bbb23ed272fc935c9fb1f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| my $path_logs = '/var/log/gifts/'; | |
| my $main_log = 'deliveries.log'; | |
| my $path_main_log = $path_logs ~ $main_log; | |
| my $max_size_log = 20000000; | |
| my $max_logs = 5; | |
| exit unless $path_main_log.IO.e; | |
| exit if $path_main_log.IO.s < $max_size_log; | |
| my @log_files = $path_logs.IO.dir.grep(/$main_log$ | $main_log\d+$/).sort; | |
| @log_files.pop.unlink if @log_files.elems == $max_logs; | |
| for @log_files.kv.reverse -> $file, $idx { $file.rename($path_main_log ~ $idx + 1); } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment