This compatibility issue breaks the "--retention" option as POSIX::strftime('%s' ...) is used to find out which files/folders should be deleted by comparing this epoch time value with the specified "--retention" parameter value.
I searched a bit and worked out a fix which does not use POSIX::strftime('%s' ...).
So here is the fix I suggest.
Basically replace occurrences of:
my $seconds_from_epoch = POSIX::strftime("%s", 1,1,1,$d,$m-1,$y-1900);
With:
my $seconds_from_epoch = timelocal(1,1,1,$d,$m-1,$y-1900);
I did tests in different timezones and the result is the same with POSIX way and with timelocal way.
You can see test script used in online interpreter in attachement:
readme.bbo.onlinetest.txt
Hi,
Environment: MS Windows Server 2016 Strawberry Perl v5.32.1 pgBadger v11.8
On MS Windows implementation (is it perl issue or pure windows issue, I'm not sure), the "%s" tag for POSIX::strftime is not supported.
See test:
As you can see, the "%s" call returns nothing.
This compatibility issue breaks the "--retention" option as
POSIX::strftime('%s' ...)
is used to find out which files/folders should be deleted by comparing this epoch time value with the specified "--retention" parameter value.I searched a bit and worked out a fix which does not use
POSIX::strftime('%s' ...)
.So here is the fix I suggest.
Basically replace occurrences of:
With:
I did tests in different timezones and the result is the same with POSIX way and with timelocal way. You can see test script used in online interpreter in attachement: readme.bbo.onlinetest.txt
The result in different timezones is:
Looks like the "POSIX::strftime("%s"..." call returns a result in the current timezone and NOT in universal time.
In the pgBadger code, here is the fix I suggest then.
Replace simply the current code ("POSIX::strftime("%s"..." calls) :
With:
I tested it and it works. The files/folders gets deleted when the retention period in weeks is exceeded.
Thanks in advance.
Bertrand