Diff for /loncom/metadata_database/cleanup_database.pl between versions 1.2 and 1.7

version 1.2, 2002/09/09 14:01:04 version 1.7, 2006/11/20 17:07:57
Line 1 Line 1
 #!/usr/bin/perl  #!/usr/bin/perl
 # The LearningOnline Network  # The LearningOnline Network
 # searchcat.pl "Search Catalog" batch script  # cleanup_database.pl Remove stale temporary search results.
 #  #
 # $Id$  # $Id$
 #  #
Line 79  use Time::Local; Line 79  use Time::Local;
 use DBI;  use DBI;
   
 my $help = 0;  my $help = 0;
 my $killtime = 86400;  my $killtime = 86400*2;
 GetOptions( "killtime=s" => \$killtime,   GetOptions( "killtime=s" => \$killtime, 
             "help"       => \$help );              "help"       => \$help );
 if ($help) {  if ($help) {
Line 119  unless ($dbh = DBI->connect("DBI:mysql:l Line 119  unless ($dbh = DBI->connect("DBI:mysql:l
   
 my $sth = $dbh->prepare("SHOW TABLE STATUS");  my $sth = $dbh->prepare("SHOW TABLE STATUS");
 $sth->execute();  $sth->execute();
 my $results = $sth->fetchall_arrayref;  my $results = $sth->fetchall_hashref('Name');
   
 foreach my $array (@$results) {  foreach my $name (keys(%$results)) {
     next if ($array->[14] ne 'temporary');  # [14] is the comment      next if ($results->{$name}{Comment} ne 'temporary'); 
     my $name = $array->[0];      my $tabletime = $results->{$name}{Update_time};
     # [10] in status report is creation time.  
     # [11] in status report is update (last modification?) time.  
     my $tabletime = $array->[11];  
     # Times are like: 2002-07-25 10:17:08      # Times are like: 2002-07-25 10:17:08
     my ($year,$month,$day,$hour,$min,$sec)=       my ($year,$month,$day,$hour,$min,$sec)= 
         ($tabletime =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);          ($tabletime =~ /(\d+)-(\d+)-(\d+) (\d+):(\d+):(\d+)/);
Line 135  foreach my $array (@$results) { Line 132  foreach my $array (@$results) {
         $dbh->do('DROP TABLE '.$name);          $dbh->do('DROP TABLE '.$name);
     }      }
 }  }
   $sth->finish();
   
 # --------------------------------------------------- Close database connection  # --------------------------------------------------- Close database connection
 $dbh->disconnect;  $dbh->disconnect;

Removed from v.1.2  
changed lines
  Added in v.1.7


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>