Kostas Kalevras wrote:

On Wed, 28 Jul 2004, Ken A wrote:


In dialup admin's perl goodies, 'clean_radacct' and 'truncate_radacct'
subtract a $days_back value of 35 or 90 from the current day of the
month (say 28). This results in negative values for the day of the
month, so the date passed to mysql is not formatted correctly.

$back_days = 90;
...

($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
$date = POSIX::strftime("%Y-%m-%d %T",$sec,$min,$hour,($mday -
$back_days),$mon,$year,$wday,$yday,$isdst);
print "$date\n";
...


Hmm, let's see:

$back_days = 90;

1:33am  /src/cvs/radiusd/dialup_admin/bin # date +"%Y-%m-%d"
2004-07-29
1:33am  /src/cvs/radiusd/dialup_admin/bin # ./clean_radacct
2004-04-30 01:33:08

So it works correctly, that's what strftime is supposed to do anyway and it
seems to be handling it just fine.


Oh!
A workaround then, for a posix issue on this old bsd system that doesn't like negative values passed to strftime().
Thanks,
Ken A



To fix, use unix time or Date::Calc

$back_days = 90;
$secs = (time()-($back_days*86400));
....

$date = POSIX::strftime("%Y-%m-%d %T",localtime($secs));
print "Removing sessions with Stop Time < $date\n";
....

Ken A


- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html



--
Kostas Kalevras         Network Operations Center
[EMAIL PROTECTED]       National Technical University of Athens, Greece
Work Phone:             +30 210 7721861
'Go back to the shadow' Gandalf

- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html



- List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to