From 31eb61bdd6661602fa51024fc115201ca16bdb63 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 18 Nov 2020 10:36:43 +0000 Subject: [PATCH] Bug 27048: Add basic timekeeping to rebuild_zebra --- misc/migration_tools/rebuild_zebra.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl index cb42164e06..fb66b0d932 100755 --- a/misc/migration_tools/rebuild_zebra.pl +++ b/misc/migration_tools/rebuild_zebra.pl @@ -209,7 +209,9 @@ if( !defined $LockFH ) { # the lockfile) }; +my $start_time = time(); if ( $verbose_logging ) { + my $pretty_time = POSIX::strftime("%H:%M:%S",$start_time); print "Zebra configuration information\n"; print "================================\n"; print "Zebra biblio directory = $biblioserverdir\n"; @@ -219,6 +221,7 @@ if ( $verbose_logging ) { print "BIBLIONUMBER in : $biblionumbertagfield\$$biblionumbertagsubfield\n"; print "BIBLIOITEMNUMBER in : $biblioitemnumbertagfield\$$biblioitemnumbertagsubfield\n"; print "================================\n"; + print "Job started: $pretty_time\n"; } my $tester = XML::LibXML->new(); @@ -267,6 +270,7 @@ if ($daemon_mode) { if ( $verbose_logging ) { + print "Indexing complete: ". pretty_time() . "\n"; print "====================\n"; print "CLEANING\n"; print "====================\n"; @@ -826,6 +830,26 @@ sub _create_lockfile { #returns undef on failure return ( $fh, $dir.'/'.LOCK_FILENAME ); } +sub pretty_time { + use integer; + my $now = time; + my $elapsed = $now - $start_time; + local $_ = $elapsed; + my ( $d, $h, $m, $s ); + $s = $_ % 60; + $_ /= 60; + $m = $_ % 60; + $_ /= 60; + $h = $_ % 24; + $_ /= 24; + $d = $_; + + my $now_pretty = POSIX::strftime("%H:%M:%S",$now); + my $elapsed_pretty = $d ? "[$d:$h:$m:$s]" : $h ? "[$h:$m:$s]" : $m ? "[$m:$s]" : "[$s]"; + + return "$now_pretty $elapsed_pretty"; +} + sub print_usage { print <<_USAGE_; $0: reindex MARC bibs and/or authorities in Zebra. -- 2.20.1