diff options
| author | Paul Buetow <paul@buetow.org> | 2011-02-06 11:10:18 +0000 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2011-02-06 11:10:18 +0000 |
| commit | dbe326833375023c1b2837d9feeb8db124739bfa (patch) | |
| tree | 2ca7656d0f0cc0f8fef73cdd83f658ea0996bc2a | |
| parent | 5e843d61702c967748dfa9c84860152113831542 (diff) | |
logrotation timestamp fixed
now using POSIX strftime instead of plain localtime()
| -rw-r--r-- | perldaemon.pl | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/perldaemon.pl b/perldaemon.pl index 3d2d11a..575c68e 100644 --- a/perldaemon.pl +++ b/perldaemon.pl @@ -4,7 +4,7 @@ use strict; use warnings; -use POSIX qw(setsid); +use POSIX qw(setsid strftime); use Shell qw(mv); use constant VERSION => 1; @@ -51,10 +51,7 @@ sub rotatelog ($) { logmsg $config => 'Rotating logfile'; - my @t = localtime(); - $t[5] += 1900; - my $timestr = "$t[5]$t[4]$t[3]-$t[2]$t[1]$t[0]"; - + my $timestr = strftime "%Y%m%d-%H%M%S", localtime(); mv($logfile, "$logfile.$timestr"); } |
