Fix DB e visualizzazione nomi hosts
This commit is contained in:
@@ -13,8 +13,9 @@ while( $_ = shift @ARGV ) {
|
||||
$start = 1 if /^\-i$/;
|
||||
}
|
||||
|
||||
my $tabella = "proxy_dati";
|
||||
my $campo = "data_destroy";
|
||||
my $tabella = "proxy_dati_storico";
|
||||
my $tabella_orig = "proxy_dati";
|
||||
my $campo = "data_destroy";
|
||||
|
||||
open CONFFILE, "< $Bin/../core/config.php" or die ("Manca file di configurazione\n");
|
||||
while (<CONFFILE>) {
|
||||
@@ -38,22 +39,30 @@ $sts = $dbmysql->prepare("use $db_name");
|
||||
$sts->execute ();
|
||||
|
||||
if ($start) {
|
||||
inizializza($dbmysql, $tabella, $campo);
|
||||
inizializza($dbmysql, $tabella, $campo, $tabella_orig);
|
||||
exit;
|
||||
}
|
||||
|
||||
aggiorna($dbmysql, $tabella, $campo);
|
||||
aggiorna($dbmysql, $tabella, $campo, $tabella_orig);
|
||||
exit;
|
||||
|
||||
|
||||
sub inizializza {
|
||||
|
||||
my $dbmysql = shift;
|
||||
my $tabella = shift;
|
||||
my $campo = shift;
|
||||
my $dbmysql = shift;
|
||||
my $tabella = shift;
|
||||
my $campo = shift;
|
||||
my $tabella_orig = shift;
|
||||
|
||||
printf "Inizio attivita' %s\n",strftime('%d-%m-%Y %H:%M:%S',localtime) if ($messaggi);
|
||||
|
||||
$copia = "INSERT INTO $tabella SELECT * FROM $tabella_orig WHERE $campo > '1970-01-01 00:00:00' AND $campo < DATE_SUB(NOW(), INTERVAL 1 DAY)";
|
||||
$rimuovi = "DELETE FROM $tabella_orig WHERE $campo > '1970-01-01 00:00:00' AND $campo < DATE_SUB(NOW(), INTERVAL 1 DAY)";
|
||||
$sts = $dbmysql->prepare($copia);
|
||||
$sts->execute ();
|
||||
$sts = $dbmysql->prepare($rimuovi);
|
||||
$sts->execute ();
|
||||
|
||||
$part = "ALTER TABLE $tabella PARTITION BY RANGE ( TO_DAYS($campo) ) (\n";
|
||||
|
||||
$query = " SELECT
|
||||
@@ -90,9 +99,17 @@ sub aggiorna {
|
||||
my $dbmysql = shift;
|
||||
my $tabella = shift;
|
||||
my $campo = shift;
|
||||
my $tabella_orig = shift;
|
||||
|
||||
printf "Inizio attivita' %s\n",strftime('%d-%m-%Y %H:%M:%S',localtime) if ($messaggi);
|
||||
|
||||
$copia = "INSERT INTO $tabella SELECT * FROM $tabella_orig WHERE $campo > '1970-01-01 00:00:00' AND $campo < DATE_SUB(NOW(), INTERVAL 1 DAY)";
|
||||
$rimuovi = "DELETE FROM $tabella_orig WHERE $campo > '1970-01-01 00:00:00' AND $campo < DATE_SUB(NOW(), INTERVAL 1 DAY)";
|
||||
$sts = $dbmysql->prepare($copia);
|
||||
$sts->execute ();
|
||||
$sts = $dbmysql->prepare($rimuovi);
|
||||
$sts->execute ();
|
||||
|
||||
$query = "SHOW CREATE TABLE $tabella";
|
||||
$sts = $dbmysql->prepare($query);
|
||||
$sts->execute ();
|
||||
|
||||
Reference in New Issue
Block a user