sql - best practices

Marcin marcin at nicram.net
Thu Apr 9 17:53:23 CEST 2015


2015-04-09 17:38 GMT+02:00 Anil Thapa <anilth at hi.is>:

>
> maybe this line should do for you
>
> /usr/bin/mysql -u radiususername -pradiuspassword  radiusdatabase -e
> "delete  from radacct where acctstoptime is not NULL ;



this clear all sessions :)

now, in other location i use perl script in cron
#v+
#!/usr/bin/perl

#use warnings;
use strict;
use locale;
use DBI;

$ENV{'PATH'}='/sbin:/usr/sbin:/usr/local/sbin:/bin:/usr/bin:/usr/local/bin';
my $dbtype = 'mysql';
my $dbhost = 'localhost';
my $dbuser = 'radius';
my $dbpasswd = 'pass';
my $dbname = 'radius';

my      $dbase =
DBI->connect("DBI:mysql:database=$dbname;host=$dbhost","$dbuser","$dbpasswd",
{ RaiseError => 1 });
        $dbase->do("SET NAMES utf8");
my      $utsfmt = "UNIX_TIMESTAMP()";


my $dbq = $dbase->prepare("UPDATE radacct SET
                                acctterminatecause = 'Script - reset',
                                acctstoptime = now()
                                WHERE (acctstarttime + INTERVAL
acctsessiontime SECOND) < (now() - INTERVAL 1200 SECOND)
                                AND acctstoptime = '0000-00-00 00:00:00'
                                ");

    $dbq->execute() or die $dbq->errstr;

$dbq->finish();
$dbase->disconnect();
#
 #v-

but i've thougt that is other solution, because i wanted to resign from
database to flat files.

-- 
>
Pozdrawiam
Marcin / nicraM


More information about the Freeradius-Users mailing list