From 5ea60d27cf8b73c748db9ab14845a0d4f12b08a0 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Thu, 9 Jan 2025 20:46:40 +0000 Subject: [PATCH] Bug 38857: Update cronjobs to log run before processing parameters A few notes: - I grabbed this list by looking for things in misc/ that had cronlogaction - I didn't touch scripts that aren't in the cronjobs directory, except fix_invalid_dates where I follow import_patrons and only log if confirmed since they aren't crons, I figure this seems reasonable - purge_suggestions I moved the logggin up and changed the addition of effective days to a verbose message - this seems more consistent To test: 1 - Enable CronjobLog 2 - On command line: perl misc/cronjobs/cleanup_database.pl --old_reservers 550 3 - Error on command line 4 - In staff client, go to Tools->Log viewer, check 'Cronjobs' and submit 5 - No entries 6 - Apply patch 7 - Repeat and see run is logged with wrong parameter 8 - Fix parameter and confirm 9 - Spot check other files until you are satisfied 10 - Sign it off! Signed-off-by: William Lavoie Signed-off-by: Martin Renvoize --- misc/cronjobs/advance_notices.pl | 2 +- .../cronjobs/automatic_item_modification_by_age.pl | 2 +- misc/cronjobs/automatic_renewals.pl | 3 +-- misc/cronjobs/batch_anonymise.pl | 3 +-- misc/cronjobs/build_browser_and_cloud.pl | 3 +-- misc/cronjobs/cart_to_shelf.pl | 3 +-- misc/cronjobs/cleanup_database.pl | 2 +- misc/cronjobs/cloud-kw.pl | 3 +-- misc/cronjobs/debar_patrons_with_fines.pl | 6 +++++- misc/cronjobs/delete_patrons.pl | 3 +-- misc/cronjobs/erm_run_harvester.pl | 3 +-- misc/cronjobs/fines.pl | 3 +-- misc/cronjobs/gather_print_notices.pl | 3 +-- misc/cronjobs/harvest_oai.pl | 3 +-- misc/cronjobs/holds/build_holds_queue.pl | 3 +-- misc/cronjobs/holds/cancel_expired_holds.pl | 3 +-- misc/cronjobs/holds/cancel_unfilled_holds.pl | 3 +-- misc/cronjobs/holds/holds_reminder.pl | 3 +-- misc/cronjobs/longoverdue.pl | 3 +-- misc/cronjobs/marc_ordering_process.pl | 3 +-- misc/cronjobs/membership_expiry.pl | 3 +-- misc/cronjobs/overdue_notices.pl | 2 +- misc/cronjobs/patron_emailer.pl | 3 +-- misc/cronjobs/process_message_queue.pl | 3 +-- misc/cronjobs/purge_suggestions.pl | 14 ++++++++------ misc/cronjobs/reconcile_balances.pl | 2 +- .../restrict_patrons_with_failed_notices.pl | 4 +++- misc/cronjobs/runreport.pl | 3 +-- misc/cronjobs/serialsUpdate.pl | 3 +-- misc/cronjobs/sftp_file.pl | 3 +-- misc/cronjobs/share_usage_with_koha_community.pl | 3 +-- misc/cronjobs/staticfines.pl | 3 +-- misc/cronjobs/update_patrons_category.pl | 5 +++-- misc/cronjobs/update_totalissues.pl | 3 +-- misc/maintenance/fix_invalid_dates.pl | 8 ++++++++ 35 files changed, 57 insertions(+), 65 deletions(-) diff --git a/misc/cronjobs/advance_notices.pl b/misc/cronjobs/advance_notices.pl index d71cd348ec5..869c4cfed54 100755 --- a/misc/cronjobs/advance_notices.pl +++ b/misc/cronjobs/advance_notices.pl @@ -186,6 +186,7 @@ my $help = 0; my $man = 0; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -217,7 +218,6 @@ END_WARN unless ($confirm) { pod2usage(1); } -cronlogaction({ info => $command_line_options }); my %branches = (); if (@branchcodes) { diff --git a/misc/cronjobs/automatic_item_modification_by_age.pl b/misc/cronjobs/automatic_item_modification_by_age.pl index 1b1ba86be65..d609aa84a44 100755 --- a/misc/cronjobs/automatic_item_modification_by_age.pl +++ b/misc/cronjobs/automatic_item_modification_by_age.pl @@ -12,6 +12,7 @@ use C4::Items; use C4::Log qw( cronlogaction ); my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); # Getting options my ( $verbose, $help, $confirm ); @@ -30,7 +31,6 @@ my $rules = eval { JSON::from_json( $syspref_content ) }; pod2usage({ -message => "Unable to load the configuration : $@", -exitval => 1 }) if $@; -cronlogaction({ info => $command_line_options }); my $report = C4::Items::ToggleNewStatus( { rules => $rules, report_only => not $confirm } ); diff --git a/misc/cronjobs/automatic_renewals.pl b/misc/cronjobs/automatic_renewals.pl index 48d18b72e4a..a3f0b92ca73 100755 --- a/misc/cronjobs/automatic_renewals.pl +++ b/misc/cronjobs/automatic_renewals.pl @@ -88,6 +88,7 @@ use Koha::Libraries; use Koha::Patrons; my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); my ( $help, $send_notices, $verbose, $confirm, $digest_per_branch ); GetOptions( @@ -130,8 +131,6 @@ To change this, edit the "EnhancedMessagingPreferences" syspref. END_WARN } -cronlogaction( { info => $command_line_options } ); - $verbose = 1 unless $verbose or $confirm; print "Test run only\n" unless $confirm; diff --git a/misc/cronjobs/batch_anonymise.pl b/misc/cronjobs/batch_anonymise.pl index 076ef83a890..4b3c32b4772 100755 --- a/misc/cronjobs/batch_anonymise.pl +++ b/misc/cronjobs/batch_anonymise.pl @@ -44,6 +44,7 @@ USAGE } my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); my ( $help, $days, $verbose ); @@ -62,8 +63,6 @@ if ( !$days ) { usage(1); } -cronlogaction({ info => $command_line_options }); - my $date = dt_from_string->subtract( days => $days ); print "Checkouts and holds before " . output_pref( { dt => $date, dateformat => 'iso', dateonly => 1 } ) . " will be anonymised.\n" diff --git a/misc/cronjobs/build_browser_and_cloud.pl b/misc/cronjobs/build_browser_and_cloud.pl index 9ac409615e6..29db2a295fb 100755 --- a/misc/cronjobs/build_browser_and_cloud.pl +++ b/misc/cronjobs/build_browser_and_cloud.pl @@ -16,6 +16,7 @@ use C4::Log; use Koha::Biblios; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); my ( $input_marc_file, $number) = ('',0); my ($version, $confirm,$field,$batch,$max_digits,$cloud_tag); @@ -59,8 +60,6 @@ my $browser_subfield = $2; warn "browser : $browser_tag / $browser_subfield" unless $batch; die "no cloud or browser field/subfield defined : nothing to do !" unless $browser_tag or $cloud_tag; -cronlogaction({ info => $command_line_options }); - my $dbh = C4::Context->dbh; my $i=0; diff --git a/misc/cronjobs/cart_to_shelf.pl b/misc/cronjobs/cart_to_shelf.pl index 96b965d89a1..7fa1acea569 100755 --- a/misc/cronjobs/cart_to_shelf.pl +++ b/misc/cronjobs/cart_to_shelf.pl @@ -38,6 +38,7 @@ use Getopt::Long qw( GetOptions ); my $hours = 0; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'h|hours=s' => \$hours, ); @@ -60,8 +61,6 @@ unless ($hours) { die "ERROR: No --hours (-h) option defined"; } -cronlogaction({ info => $command_line_options }); - my $query = "SELECT itemnumber FROM items WHERE location = 'CART' AND TIMESTAMPDIFF(HOUR, items.timestamp, NOW() ) > ?"; my $sth = C4::Context->dbh->prepare($query); $sth->execute($hours); diff --git a/misc/cronjobs/cleanup_database.pl b/misc/cronjobs/cleanup_database.pl index d76499b8734..306628472b5 100755 --- a/misc/cronjobs/cleanup_database.pl +++ b/misc/cronjobs/cleanup_database.pl @@ -174,6 +174,7 @@ my $reports; my $edifact_msg_days; my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); GetOptions( 'h|help' => \$help, @@ -297,7 +298,6 @@ if ( $pDebarments && $allDebarments ) { say "Confirm flag not passed, running in dry-run mode..." unless $confirm; -cronlogaction( { info => $command_line_options } ); my $dbh = C4::Context->dbh(); my $sth; diff --git a/misc/cronjobs/cloud-kw.pl b/misc/cronjobs/cloud-kw.pl index 33c6a56013b..b996ac20c59 100755 --- a/misc/cronjobs/cloud-kw.pl +++ b/misc/cronjobs/cloud-kw.pl @@ -35,6 +35,7 @@ my $help = 0; my $conf = ''; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'verbose' => \$verbose, @@ -49,8 +50,6 @@ sub usage { usage() if $help || !$conf; -cronlogaction({ info => $command_line_options }); - my @clouds; print "Reading configuration file: $conf\n" if $verbose; eval { diff --git a/misc/cronjobs/debar_patrons_with_fines.pl b/misc/cronjobs/debar_patrons_with_fines.pl index cb166121e82..e5f7f1bc397 100755 --- a/misc/cronjobs/debar_patrons_with_fines.pl +++ b/misc/cronjobs/debar_patrons_with_fines.pl @@ -76,6 +76,9 @@ use Koha::Patron::Debarments; use C4::Log qw( cronlogaction ); +my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); + my ( $amount, $help, $confirm, $message, $expiration, $file, $verbose ); GetOptions( 'a|amount:i' => \$amount, @@ -89,7 +92,6 @@ GetOptions( pod2usage(1) if $help; pod2usage(1) unless $message || $file; -cronlogaction(); my $patrons = Koha::Patrons->filter_by_amount_owed( { more_than => $amount // 0 } ); $message = getMessageContent(); @@ -126,6 +128,8 @@ my $verb = $confirm ? 'Debarred' : 'Found'; print "debar_patrons_with_fines: $verb $count_patrons patrons"; print( $errors ? ", had $errors failures\n" : "\n" ); +cronlogaction({ action => 'End', info => "COMPLETED" }); + sub getMessageContent { return $message if ($message); open( my $FH, "<:encoding(UTF-8)", $file ) or die "Could not open $file: $!\n"; diff --git a/misc/cronjobs/delete_patrons.pl b/misc/cronjobs/delete_patrons.pl index 7962233efa2..5484fbf7de9 100755 --- a/misc/cronjobs/delete_patrons.pl +++ b/misc/cronjobs/delete_patrons.pl @@ -15,6 +15,7 @@ my ( $help, $verbose, $not_borrowed_since, $expired_before, $last_seen, @category_code, $branchcode, $file, $confirm ); my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'h|help' => \$help, @@ -46,8 +47,6 @@ unless ( $not_borrowed_since or $expired_before or $last_seen or @category_code pod2usage(q{At least one filter is mandatory}); } -cronlogaction({ info => $command_line_options }); - my @file_members; if ($file) { open(my $fh, '<:encoding(UTF-8)', $file) or die "Could not open file $file' $!"; diff --git a/misc/cronjobs/erm_run_harvester.pl b/misc/cronjobs/erm_run_harvester.pl index cbb999fb1f0..134c1487aee 100755 --- a/misc/cronjobs/erm_run_harvester.pl +++ b/misc/cronjobs/erm_run_harvester.pl @@ -100,6 +100,7 @@ C $command_line_options } ); # Command line option values my $help = 0; @@ -131,8 +132,6 @@ unless ($begin_date) { pod2usage(1); } -cronlogaction( { info => $command_line_options } ); - debug_msg("Dry run: Harvests will not be enqueued") if $dry_run; while ( my $udprovider = $udproviders->next ) { debug_msg( diff --git a/misc/cronjobs/fines.pl b/misc/cronjobs/fines.pl index a32562ad3a5..c3b1b2c04dd 100755 --- a/misc/cronjobs/fines.pl +++ b/misc/cronjobs/fines.pl @@ -51,6 +51,7 @@ my $maxdays; my $verify_issue; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'h|help' => \$help, @@ -96,8 +97,6 @@ catch { exit; }; -cronlogaction({ info => $command_line_options }); - my @borrower_fields = qw(cardnumber categorycode surname firstname email phone address citystate); my @item_fields = qw(itemnumber barcode date_due); diff --git a/misc/cronjobs/gather_print_notices.pl b/misc/cronjobs/gather_print_notices.pl index 8cd325e9049..5f7dfdcde78 100755 --- a/misc/cronjobs/gather_print_notices.pl +++ b/misc/cronjobs/gather_print_notices.pl @@ -30,6 +30,7 @@ my ( ); my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); $send = 1; GetOptions( @@ -74,8 +75,6 @@ if ( $ods and @letter_codes != 1 ) { $delimiter ||= q|,|; -cronlogaction({ info => $command_line_options }); - my $today_iso = output_pref( { dt => dt_from_string, dateonly => 1, dateformat => 'iso' } ) ; my $today_syspref = output_pref( { dt => dt_from_string, dateonly => 1 } ); diff --git a/misc/cronjobs/harvest_oai.pl b/misc/cronjobs/harvest_oai.pl index 050232a6752..8201844479d 100755 --- a/misc/cronjobs/harvest_oai.pl +++ b/misc/cronjobs/harvest_oai.pl @@ -29,6 +29,7 @@ use C4::Log qw( cronlogaction ); use Try::Tiny qw( catch try ); my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); my ( $help, $verbose, $id, $days, $list, $force ); @@ -99,8 +100,6 @@ try { exit; }; -cronlogaction( { info => $command_line_options } ); - my $harvester = Koha::OAI::Client::Harvester->new( { server => $server, days => $days, force => $force, logger => \&logFunction } ); $harvester->init(); diff --git a/misc/cronjobs/holds/build_holds_queue.pl b/misc/cronjobs/holds/build_holds_queue.pl index 1906b5723b6..0659ed31e96 100755 --- a/misc/cronjobs/holds/build_holds_queue.pl +++ b/misc/cronjobs/holds/build_holds_queue.pl @@ -65,6 +65,7 @@ my $force = 0; my $unallocated = 0; my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); GetOptions( 'h|help' => \$help, @@ -83,8 +84,6 @@ if ( $rthq && !$force ) { exit(1); } -cronlogaction( { info => $command_line_options } ); - my $loops = C4::Context->preference('HoldsQueueParallelLoopsCount'); CreateQueue( { loops => $loops, unallocated => $unallocated } ); diff --git a/misc/cronjobs/holds/cancel_expired_holds.pl b/misc/cronjobs/holds/cancel_expired_holds.pl index ed977678b70..9a4e8d27fee 100755 --- a/misc/cronjobs/holds/cancel_expired_holds.pl +++ b/misc/cronjobs/holds/cancel_expired_holds.pl @@ -66,6 +66,7 @@ my $help = 0; my $reason; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -73,8 +74,6 @@ GetOptions( ) or pod2usage(1); pod2usage(1) if $help; -cronlogaction({ info => $command_line_options }); - C4::Reserves::CancelExpiredReserves($reason); cronlogaction({ action => 'End', info => "COMPLETED" }); diff --git a/misc/cronjobs/holds/cancel_unfilled_holds.pl b/misc/cronjobs/holds/cancel_unfilled_holds.pl index 01eff71a3a0..b1506bfb0c3 100755 --- a/misc/cronjobs/holds/cancel_unfilled_holds.pl +++ b/misc/cronjobs/holds/cancel_unfilled_holds.pl @@ -86,6 +86,7 @@ my $confirm = 0; my $reason; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'h|help|?' => \$help, @@ -108,8 +109,6 @@ qq{\nError: You must specify a value for days waiting to cancel holds.\n}, ); } -cronlogaction({ info => $command_line_options }); - warn "Running in test mode, no actions will be taken" unless ($confirm); $verbose and warn "Looking for unfilled holds placed $days or more days ago\n"; diff --git a/misc/cronjobs/holds/holds_reminder.pl b/misc/cronjobs/holds/holds_reminder.pl index 36900419d31..a15b7803126 100755 --- a/misc/cronjobs/holds/holds_reminder.pl +++ b/misc/cronjobs/holds/holds_reminder.pl @@ -177,6 +177,7 @@ my $opt_out = 0; my @mtts; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -196,8 +197,6 @@ pod2usage( -verbose => 2 ) if $man; $lettercode ||= 'HOLD_REMINDER'; -cronlogaction({ info => $command_line_options }); - # Unless a delay is specified by the user we target all waiting holds unless (defined $days) { $days=0; diff --git a/misc/cronjobs/longoverdue.pl b/misc/cronjobs/longoverdue.pl index d761524b24b..4da8846d65e 100755 --- a/misc/cronjobs/longoverdue.pl +++ b/misc/cronjobs/longoverdue.pl @@ -56,6 +56,7 @@ my $list_itemtypes = 0; my @skip_lost_values; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'l|lost=s%' => \$lost, @@ -320,8 +321,6 @@ unless ($confirm) { print "### TEST MODE -- NO ACTIONS TAKEN ###\n"; } -cronlogaction({ info => $command_line_options }); - # In my opinion, this line is safe SQL to have outside the API. --atz our $bounds_sth = C4::Context->dbh->prepare("SELECT DATE_SUB(CURDATE(), INTERVAL ? DAY)"); diff --git a/misc/cronjobs/marc_ordering_process.pl b/misc/cronjobs/marc_ordering_process.pl index 657203bcdde..d01767cb2ee 100755 --- a/misc/cronjobs/marc_ordering_process.pl +++ b/misc/cronjobs/marc_ordering_process.pl @@ -67,6 +67,7 @@ use Koha::MarcOrderAccounts; use C4::Log qw( cronlogaction ); my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); my ( $help, $verbose, $confirm, $delete ); GetOptions( @@ -78,8 +79,6 @@ GetOptions( pod2usage(0) if $help; -cronlogaction( { info => $command_line_options } ); - $verbose = 1 unless $verbose or $confirm; print "Test run only\n" unless $confirm; diff --git a/misc/cronjobs/membership_expiry.pl b/misc/cronjobs/membership_expiry.pl index 3d0a53a05e1..03f0039257f 100755 --- a/misc/cronjobs/membership_expiry.pl +++ b/misc/cronjobs/membership_expiry.pl @@ -179,6 +179,7 @@ my $letter_expiry; my $letter_renew; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -226,8 +227,6 @@ if ( !C4::Context->preference('TrackLastPatronActivityTriggers') ); } -cronlogaction({ info => $command_line_options }); - my $expdays = C4::Context->preference('MembershipExpiryDaysNotice'); if( !$expdays ) { #If the pref is not set, we will exit diff --git a/misc/cronjobs/overdue_notices.pl b/misc/cronjobs/overdue_notices.pl index 5e243616991..3a70377e2dc 100755 --- a/misc/cronjobs/overdue_notices.pl +++ b/misc/cronjobs/overdue_notices.pl @@ -312,6 +312,7 @@ my @myborcatout; my ( $date_input, $today ); my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -335,7 +336,6 @@ GetOptions( ) or pod2usage(2); pod2usage(1) if $help; pod2usage( -verbose => 2 ) if $man; -cronlogaction({ info => $command_line_options }); if ( defined $csvfilename && $csvfilename =~ /^-/ ) { warn qq(using "$csvfilename" as filename, that seems odd); diff --git a/misc/cronjobs/patron_emailer.pl b/misc/cronjobs/patron_emailer.pl index 1fcc93ccd79..893a0fb760a 100755 --- a/misc/cronjobs/patron_emailer.pl +++ b/misc/cronjobs/patron_emailer.pl @@ -118,6 +118,7 @@ my $error_msgs = { }; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -133,8 +134,6 @@ GetOptions( pod2usage(1) if $help; pod2usage(1) unless $report_id && $notice && $module; -cronlogaction({ info => $command_line_options }); - my ( $emails, $errors ) = C4::Reports::Guided::EmailReport({ email => $email, from => $from, diff --git a/misc/cronjobs/process_message_queue.pl b/misc/cronjobs/process_message_queue.pl index ebaa7230f0f..0078d285553 100755 --- a/misc/cronjobs/process_message_queue.pl +++ b/misc/cronjobs/process_message_queue.pl @@ -38,6 +38,7 @@ my @letter_code; my $exit_on_plugin_failure = 0; my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); GetOptions( 'u|username:s' => \$username, @@ -86,8 +87,6 @@ try { exit; }; -cronlogaction( { info => $command_line_options } ); - # Remove empty elements, see bug 37075 @letter_code = grep { $_ ne q{} } @letter_code; diff --git a/misc/cronjobs/purge_suggestions.pl b/misc/cronjobs/purge_suggestions.pl index f4fba6e0832..3a07bf13e13 100755 --- a/misc/cronjobs/purge_suggestions.pl +++ b/misc/cronjobs/purge_suggestions.pl @@ -26,14 +26,16 @@ use C4::Suggestions; use C4::Log qw( cronlogaction ); use C4::Context; -my ( $help, $days, $confirm ); +my ( $help, $days, $confirm, $verbose ); my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( - 'help|?' => \$help, - 'days:i' => \$days, - 'confirm'=> \$confirm, + 'help|?' => \$help, + 'days:i' => \$days, + 'confirm' => \$confirm, + 'v|verbose' => \$verbose, ); my $usage = << 'ENDUSAGE'; @@ -42,6 +44,7 @@ Parameters: -help|? This message -days TTT to define the age of suggestions to delete -confirm flag needed to confirm purge operation +-verbose flag to increase feedback The days parameter falls back to the value of system preference PurgeSuggestionsOlderThan. Suggestions are deleted only for a positive @@ -59,8 +62,7 @@ if( !$confirm || $help || !defined($days) ) { print "No confirm parameter passed!\n\n" if !$confirm && !$help; print $usage; } elsif( $days and $days > 0 ) { - $command_line_options .= " ( effective days = $days )"; - cronlogaction({ info => $command_line_options }); + print "Purging suggestions older than $days days\n" if $verbose; DelSuggestionsOlderThan($days); } else { warn "This script requires a positive number of days. Aborted.\n"; diff --git a/misc/cronjobs/reconcile_balances.pl b/misc/cronjobs/reconcile_balances.pl index 5d2c3689792..710149a7d61 100755 --- a/misc/cronjobs/reconcile_balances.pl +++ b/misc/cronjobs/reconcile_balances.pl @@ -65,6 +65,7 @@ my $help = 0; my $verbose = 0; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help' => \$help, @@ -72,7 +73,6 @@ GetOptions( ) or pod2usage(2); pod2usage(1) if $help; -cronlogaction({ info => $command_line_options }); my @patron_ids = Koha::Account::Lines->search( { diff --git a/misc/cronjobs/restrict_patrons_with_failed_notices.pl b/misc/cronjobs/restrict_patrons_with_failed_notices.pl index e6c1ec2fde9..3aed1c84cbb 100755 --- a/misc/cronjobs/restrict_patrons_with_failed_notices.pl +++ b/misc/cronjobs/restrict_patrons_with_failed_notices.pl @@ -28,6 +28,9 @@ use Koha::Patrons; use C4::Letters; use Koha::Notice::Message; +my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); + # Getting options my ( $help, $verbose, $confirm ); GetOptions( @@ -47,7 +50,6 @@ Exiting cronjob END_WARN } -cronlogaction(); my @failed_notices = Koha::Notice::Messages->get_failed_notices( { days => 7 } )->as_list; diff --git a/misc/cronjobs/runreport.pl b/misc/cronjobs/runreport.pl index f1a51d6975a..3bd1f002e97 100755 --- a/misc/cronjobs/runreport.pl +++ b/misc/cronjobs/runreport.pl @@ -205,6 +205,7 @@ my $password = undef; my $method = 'LOGIN'; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|?' => \$help, @@ -231,8 +232,6 @@ pod2usage( -verbose => 2 ) if ($man); pod2usage( -verbose => 2 ) if ($help and $verbose); pod2usage(1) if $help; -cronlogaction({ info => $command_line_options }); - unless ($format) { $verbose and print STDERR "No format specified, assuming 'text'\n"; $format = 'text'; diff --git a/misc/cronjobs/serialsUpdate.pl b/misc/cronjobs/serialsUpdate.pl index b6166ee3a80..2d1ccaae039 100755 --- a/misc/cronjobs/serialsUpdate.pl +++ b/misc/cronjobs/serialsUpdate.pl @@ -60,6 +60,7 @@ my $note = ''; my $nonote = 0; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'help|h|?' => \$help, @@ -73,8 +74,6 @@ GetOptions( pod2usage(1) if $help; pod2usage( -verbose => 2 ) if $man; -cronlogaction({ info => $command_line_options }); - $verbose and !$confirm and print "### Database will not be modified ###\n"; if ( $note && $nonote ) { diff --git a/misc/cronjobs/sftp_file.pl b/misc/cronjobs/sftp_file.pl index e769ac19147..c1bb8aeb3cc 100755 --- a/misc/cronjobs/sftp_file.pl +++ b/misc/cronjobs/sftp_file.pl @@ -127,6 +127,7 @@ my $status_email_message = undef; my $sftp_status = undef; my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); GetOptions( 'help|?' => \$help, @@ -144,8 +145,6 @@ pod2usage( -verbose => 2 ) if ($man); pod2usage( -verbose => 2 ) if ( $help and $verbose ); pod2usage(1) if $help; -cronlogaction( { info => $command_line_options } ); - # Check we have all the SFTP details we need if ( !$user || !$pass || !$host || !$upload_dir ) { pod2usage(q|Please provide details for sftp username, password, upload directory, and host|); diff --git a/misc/cronjobs/share_usage_with_koha_community.pl b/misc/cronjobs/share_usage_with_koha_community.pl index 671bbe1a1a4..c534bdb1e70 100755 --- a/misc/cronjobs/share_usage_with_koha_community.pl +++ b/misc/cronjobs/share_usage_with_koha_community.pl @@ -12,6 +12,7 @@ use C4::Log qw( cronlogaction ); use POSIX qw( strftime ); my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); my ( $help, $verbose, $force, $quiet ); GetOptions( @@ -38,8 +39,6 @@ Setting the quiet flag will silence this message. exit 1; } -cronlogaction({ info => $command_line_options }); - my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() ); if ($need_update) { diff --git a/misc/cronjobs/staticfines.pl b/misc/cronjobs/staticfines.pl index 208cc8a2042..dafbbacb038 100755 --- a/misc/cronjobs/staticfines.pl +++ b/misc/cronjobs/staticfines.pl @@ -53,6 +53,7 @@ my $debug = 0; my $bigdebug = 0; my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); GetOptions( 'h|help' => \$help, @@ -83,8 +84,6 @@ This script has the following parameters : ENDUSAGE die $usage if $help; -cronlogaction({ info => $command_line_options }); - my $dbh = C4::Context->dbh; # Processing categories diff --git a/misc/cronjobs/update_patrons_category.pl b/misc/cronjobs/update_patrons_category.pl index aafbf86aa58..f9b00a7bb15 100755 --- a/misc/cronjobs/update_patrons_category.pl +++ b/misc/cronjobs/update_patrons_category.pl @@ -170,6 +170,9 @@ my $branch_lim; my %fields; my @where; +my $command_line_options = join(" ",@ARGV); +cronlogaction({ info => $command_line_options }); + GetOptions( 'help|?' => \$help, 'man' => \$man, @@ -202,8 +205,6 @@ if ( not $fromcat && $tocat ) { #make sure we've specified the info we need. $verbose and print "Will update patrons from $fromcat to $tocat with conditions below (if any)\n"; -cronlogaction(); - my %params; if ( $reg_bef || $reg_aft ) { diff --git a/misc/cronjobs/update_totalissues.pl b/misc/cronjobs/update_totalissues.pl index 10763617d04..c16a19859df 100755 --- a/misc/cronjobs/update_totalissues.pl +++ b/misc/cronjobs/update_totalissues.pl @@ -53,6 +53,7 @@ my $progress = 100; my $unit; my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); my $result = GetOptions( 'v|verbose' => \$verbose, @@ -89,8 +90,6 @@ unless ( $usestats || $useitems ) { usage() if $want_help; -cronlogaction( { info => $command_line_options } ); - my $dbh = C4::Context->dbh; my $num_bibs_processed = 0; diff --git a/misc/maintenance/fix_invalid_dates.pl b/misc/maintenance/fix_invalid_dates.pl index 4a4cf993194..e244aad8aa2 100755 --- a/misc/maintenance/fix_invalid_dates.pl +++ b/misc/maintenance/fix_invalid_dates.pl @@ -40,11 +40,19 @@ This script fixes any date fields in the database that have '0000-00-00' values my $verbose = 0; my $doit = 0; +my $command_line_options = join( " ", @ARGV ); + GetOptions( 'v|verbose' => \$verbose, 'c|confirm' => \$doit, ); +if ($doit) { + cronlogaction( { action => 'Run', info => $command_line_options } ); +} else { + warn "Running in dry-run mode, provide --confirm to apply the changes\n"; +} + my $schema = Koha::Database->new->schema; # Loop over all the DBIx::Class classes -- 2.47.1