@@ -, +, @@
- Got to system preferences and set 'CronjobLog' to: [Log] information from
cron jobs.
- Run some cron jobs
- Go to Home > Tools > Logs
- Verify that you have a selection 'Cron jobs' in drop-down 'Module'. Select it
with Action "All" and Submit.
- Output should show Date/time and info about Cron jobs
- Merge both patches, and fix updatedatabase.pl
- Works as described. Provide intersting feedback from cronjob scripts.
--
---
C4/Log.pm | 22 ++++++++++++++++++----
.../bug_13889_add_cronjoblog_syspref.sql | 1 +
installer/data/mysql/sysprefs.sql | 1 +
.../prog/en/modules/admin/preferences/logs.pref | 6 ++++++
.../intranet-tmpl/prog/en/modules/tools/viewlog.tt | 3 ++-
misc/cronjobs/advance_notices.pl | 4 ++++
misc/cronjobs/automatic_renewals.pl | 3 +++
misc/cronjobs/batch_anonymise.pl | 3 +++
misc/cronjobs/build_browser_and_cloud.pl | 4 ++++
misc/cronjobs/cart_to_shelf.pl | 3 +++
misc/cronjobs/cleanup_database.pl | 5 +++--
misc/cronjobs/cloud-kw.pl | 3 ++-
misc/cronjobs/delete_expired_opac_registrations.pl | 3 +++
misc/cronjobs/delete_patrons.pl | 3 +++
.../delete_unverified_opac_registrations.pl | 3 +++
misc/cronjobs/fines.pl | 3 +++
misc/cronjobs/gather_print_notices.pl | 3 +++
misc/cronjobs/holds/auto_unsuspend_holds.pl | 3 +++
misc/cronjobs/holds/build_holds_queue.pl | 3 +++
misc/cronjobs/holds/cancel_expired_holds.pl | 3 +++
misc/cronjobs/j2a.pl | 3 +++
misc/cronjobs/longoverdue.pl | 3 +++
misc/cronjobs/overdue_notices.pl | 5 +++--
misc/cronjobs/process_message_queue.pl | 3 +++
misc/cronjobs/purge_suggestions.pl | 2 ++
misc/cronjobs/runreport.pl | 3 +++
misc/cronjobs/serialsUpdate.pl | 3 +++
misc/cronjobs/share_usage_with_koha_community.pl | 3 +++
misc/cronjobs/staticfines.pl | 3 +++
misc/cronjobs/update_totalissues.pl | 3 +++
30 files changed, 103 insertions(+), 10 deletions(-)
create mode 100644 installer/data/mysql/atomicupdate/bug_13889_add_cronjoblog_syspref.sql
--- a/C4/Log.pm
+++ a/C4/Log.pm
@@ -30,11 +30,11 @@ use C4::Dates qw(format_date);
use vars qw($VERSION @ISA @EXPORT);
BEGIN {
- # set the version for version checking
+ # set the version for version checking
$VERSION = 3.07.00.049;
- require Exporter;
- @ISA = qw(Exporter);
- @EXPORT = qw(&logaction &GetLogStatus &displaylog &GetLogs);
+ require Exporter;
+ @ISA = qw(Exporter);
+ @EXPORT = qw(&logaction &cronlogaction &GetLogStatus &displaylog &GetLogs);
}
=head1 NAME
@@ -81,6 +81,20 @@ sub logaction {
$sth->finish;
}
+=item cronlogaction
+
+ &cronlogaction();
+
+Convenience routine to add a record into action_logs table from a cron job.
+
+=cut
+
+#'
+sub cronlogaction {
+ logaction( 'CRONJOBS', 'Run', 0, (caller(0))[1] ) if C4::Context->preference('CronjobLog');
+}
+
+
=item GetLogStatus
$status = GetLogStatus;
--- a/installer/data/mysql/atomicupdate/bug_13889_add_cronjoblog_syspref.sql
+++ a/installer/data/mysql/atomicupdate/bug_13889_add_cronjoblog_syspref.sql
@@ -0,0 +1, @@
+INSERT IGNORE INTO systempreferences (variable,value,explanation,options,type) VALUES ('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo');
--- a/installer/data/mysql/sysprefs.sql
+++ a/installer/data/mysql/sysprefs.sql
@@ -90,6 +90,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('CoceProviders', NULL, 'aws,gb,ol', 'Coce providers', 'multiple'),
('COinSinOPACResults','1','','If ON, use COinS in OPAC search results page. NOTE: this can slow down search response time significantly','YesNo'),
('ConfirmFutureHolds','0','','Number of days for confirming future holds','Integer'),
+('CronjobLog','0',NULL,'If ON, log information from cron jobs.','YesNo'),
('CurrencyFormat','US','US|FR','Determines the display format of currencies. eg: \'36000\' is displayed as \'360 000,00\' in \'FR\' or \'360,000.00\' in \'US\'.','Choice'),
('dateformat','us','metric|us|iso','Define global date format (us mm/dd/yyyy, metric dd/mm/yyy, ISO yyyy-mm-dd)','Choice'),
('DebugLevel','2','0|1|2','Define the level of debugging information sent to the browser when errors are encountered (set to 0 in production). 0=none, 1=some, 2=most','Choice'),
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/logs.pref
@@ -47,3 +47,9 @@ Logging:
on: Log
off: "Don't log"
- when serials are added, deleted or changed.
+ -
+ - pref: CronjobLog
+ choices:
+ on: Log
+ off: "Don't log"
+ - information from cron jobs.
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/viewlog.tt
@@ -25,6 +25,7 @@
[% CASE 'LETTER' %]Letter
[% CASE 'FINES' %]Fines
[% CASE 'SYSTEMPREFERENCE' %]System prefs
+[% CASE 'CRONJOBS' %]Cron jobs
[% CASE %][% module %]
[% END %]
[% END %]
@@ -75,7 +76,7 @@
[% ELSE %]
[% END %]
- [% FOREACH modx IN [ 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' ] %]
+ [% FOREACH modx IN [ 'CATALOGUING' 'AUTHORITIES' 'MEMBERS' 'ACQUISITIONS' 'SERIAL' 'CIRCULATION' 'LETTER' 'FINES' 'SYSTEMPREFERENCE' 'CRONJOBS' ] %]
[% IF modules.grep(modx).size %]
[% ELSE %]
--- a/misc/cronjobs/advance_notices.pl
+++ a/misc/cronjobs/advance_notices.pl
@@ -56,6 +56,7 @@ use C4::Members;
use C4::Members::Messaging;
use C4::Overdues;
use Koha::DateUtils;
+use C4::Log;
=head1 NAME
@@ -199,6 +200,9 @@ END_WARN
unless ($confirm) {
pod2usage(1);
}
+
+cronlogaction();
+
# The fields that will be substituted into <>
my @item_content_fields = split(/,/,$itemscontent);
--- a/misc/cronjobs/automatic_renewals.pl
+++ a/misc/cronjobs/automatic_renewals.pl
@@ -44,6 +44,9 @@ use Modern::Perl;
use C4::Circulation;
use C4::Context;
+use C4::Log;
+
+cronlogaction();
my $dbh = C4::Context->dbh;
my ( $borrowernumber, $itemnumber, $branch, $ok, $error );
--- a/misc/cronjobs/batch_anonymise.pl
+++ a/misc/cronjobs/batch_anonymise.pl
@@ -37,6 +37,7 @@ use Date::Calc qw(
Add_Delta_Days
);
use Getopt::Long;
+use C4::Log;
sub usage {
print STDERR <dbh;
my $i=0;
--- a/misc/cronjobs/cart_to_shelf.pl
+++ a/misc/cronjobs/cart_to_shelf.pl
@@ -29,6 +29,7 @@ use strict;
use warnings;
use C4::Items qw/ CartToShelf /;
+use C4::Log;
BEGIN {
@@ -63,6 +64,8 @@ unless ($hours) {
die "ERROR: No --hours (-h) option defined";
}
+cronlogaction();
+
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);
--- a/misc/cronjobs/cleanup_database.pl
+++ a/misc/cronjobs/cleanup_database.pl
@@ -36,10 +36,9 @@ BEGIN {
use C4::Context;
use C4::Dates;
-
use C4::Search;
-
use Getopt::Long;
+use C4::Log;
sub usage {
print STDERR <dbh();
my $sth;
my $sth2;
--- a/misc/cronjobs/cloud-kw.pl
+++ a/misc/cronjobs/cloud-kw.pl
@@ -26,7 +26,7 @@ use YAML::Syck;
use Pod::Usage;
use Getopt::Long;
use C4::Context;
-
+use C4::Log;
my $verbose = 0;
my $help = 0;
@@ -44,6 +44,7 @@ sub usage {
usage() if $help || !$conf;
+cronlogaction();
my @clouds;
print "Reading configuration file: $conf\n" if $verbose;
--- a/misc/cronjobs/delete_expired_opac_registrations.pl
+++ a/misc/cronjobs/delete_expired_opac_registrations.pl
@@ -30,6 +30,7 @@ BEGIN {
use C4::Context;
use C4::Members qw/ DelMember /;
+use C4::Log;
my $help;
my $confirm;
@@ -63,6 +64,8 @@ if ( $help || !$confirm ) {
exit;
}
+cronlogaction();
+
# Delete accounts that haven't been upgraded from the 'temporary' category code
my $delay =
C4::Context->preference('PatronSelfRegistrationExpireTemporaryAccountsDelay');
--- a/misc/cronjobs/delete_patrons.pl
+++ a/misc/cronjobs/delete_patrons.pl
@@ -8,6 +8,7 @@ use Getopt::Long;
use C4::Members;
use C4::VirtualShelves;
use Koha::DateUtils;
+use C4::Log;
my ( $help, $verbose, $not_borrowed_since, $expired_before, $category_code,
$branchcode, $confirm );
@@ -36,6 +37,8 @@ unless ( $not_borrowed_since or $expired_before or $category_code or $branchcode
exit;
}
+cronlogaction();
+
my $members = GetBorrowersToExpunge(
{
not_borrowered_since => $not_borrowed_since,
--- a/misc/cronjobs/delete_unverified_opac_registrations.pl
+++ a/misc/cronjobs/delete_unverified_opac_registrations.pl
@@ -30,6 +30,7 @@ BEGIN {
use C4::Context;
use C4::Members qw/ DelMember /;
+use C4::Log;
my $help;
my $confirm;
@@ -59,6 +60,8 @@ if ( $help || !$confirm ) {
exit;
}
+cronlogaction();
+
my $dbh = C4::Context->dbh;
$dbh->do( "
--- a/misc/cronjobs/fines.pl
+++ a/misc/cronjobs/fines.pl
@@ -38,6 +38,7 @@ use File::Spec;
use Koha::Calendar;
use Koha::DateUtils;
+use C4::Log;
my $help;
my $verbose;
@@ -70,6 +71,8 @@ if ($help) {
exit;
}
+cronlogaction();
+
my @borrower_fields =
qw(cardnumber categorycode surname firstname email phone address citystate);
my @item_fields = qw(itemnumber barcode date_due);
--- a/misc/cronjobs/gather_print_notices.pl
+++ a/misc/cronjobs/gather_print_notices.pl
@@ -36,6 +36,7 @@ use C4::Letters;
use C4::Templates;
use File::Spec;
use Getopt::Long;
+use C4::Log;
sub usage {
print STDERR <new();
my @all_messages = @{ GetPrintMessages() };
exit unless (@all_messages);
--- a/misc/cronjobs/holds/auto_unsuspend_holds.pl
+++ a/misc/cronjobs/holds/auto_unsuspend_holds.pl
@@ -30,5 +30,8 @@ BEGIN {
# cancel all expired hold requests
use C4::Reserves;
+use C4::Log;
+
+cronlogaction();
AutoUnsuspendReserves();
--- a/misc/cronjobs/holds/build_holds_queue.pl
+++ a/misc/cronjobs/holds/build_holds_queue.pl
@@ -16,6 +16,9 @@ BEGIN {
}
use C4::HoldsQueue qw(CreateQueue);
+use C4::Log;
+
+cronlogaction();
CreateQueue();
--- a/misc/cronjobs/holds/cancel_expired_holds.pl
+++ a/misc/cronjobs/holds/cancel_expired_holds.pl
@@ -30,5 +30,8 @@ BEGIN {
# cancel all expired hold requests
use C4::Reserves;
+use C4::Log;
+
+cronlogaction();
CancelExpiredReserves();
--- a/misc/cronjobs/j2a.pl
+++ a/misc/cronjobs/j2a.pl
@@ -32,6 +32,7 @@ use C4::Context;
use C4::Members;
use Getopt::Long;
use Pod::Usage;
+use C4::Log;
=head1 NAME
@@ -126,6 +127,8 @@ if(not $fromcat && $tocat) { #make sure we've specified the info we need.
exit;
}
+cronlogaction();
+
my $dbh=C4::Context->dbh;
my @branches = C4::Branch::GetBranches();
#get today's date, format it and subtract upperagelimit
--- a/misc/cronjobs/longoverdue.pl
+++ a/misc/cronjobs/longoverdue.pl
@@ -37,6 +37,7 @@ use C4::Context;
use C4::Items;
use C4::Circulation qw/LostItem/;
use Getopt::Long;
+use C4::Log;
my $lost; # key=lost value, value=num days.
my ($charge, $verbose, $confirm, $quiet);
@@ -129,6 +130,8 @@ unless ($confirm) {
print "### TEST MODE -- NO ACTIONS TAKEN ###\n";
}
+cronlogaction();
+
# 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)");
--- a/misc/cronjobs/overdue_notices.pl
+++ a/misc/cronjobs/overdue_notices.pl
@@ -43,11 +43,10 @@ use C4::Debug;
use C4::Letters;
use C4::Overdues qw(GetFine GetOverdueMessageTransportTypes);
use C4::Budgets qw(GetCurrency);
-use Koha::DateUtils;
-
use Koha::Borrower::Debarments qw(AddUniqueDebarment);
use Koha::DateUtils;
use Koha::Calendar;
+use C4::Log;
=head1 NAME
@@ -316,6 +315,8 @@ GetOptions(
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
+cronlogaction();
+
if ( defined $csvfilename && $csvfilename =~ /^-/ ) {
warn qq(using "$csvfilename" as filename, that seems odd);
}
--- a/misc/cronjobs/process_message_queue.pl
+++ a/misc/cronjobs/process_message_queue.pl
@@ -26,6 +26,7 @@ BEGIN {
eval { require "$FindBin::Bin/../kohalib.pl" };
}
use C4::Letters;
+use C4::Log;
use Getopt::Long;
my $username = undef;
@@ -60,5 +61,7 @@ ENDUSAGE
die $usage if $help;
+cronlogaction();
+
C4::Letters::SendQueuedMessages( { verbose => $verbose, username => $username, password => $password, method => $method } );
--- a/misc/cronjobs/purge_suggestions.pl
+++ a/misc/cronjobs/purge_suggestions.pl
@@ -32,6 +32,7 @@ BEGIN {
use Getopt::Long;
use Pod::Usage;
use C4::Suggestions;
+use C4::Log;
my ($help, $days);
@@ -55,6 +56,7 @@ EOF
}
if($days){
+ cronlogaction();
DelSuggestionsOlderThan($days);
}
--- a/misc/cronjobs/runreport.pl
+++ a/misc/cronjobs/runreport.pl
@@ -24,6 +24,7 @@ use warnings;
use C4::Reports::Guided; # 0.12
use C4::Context;
use Koha::Email;
+use C4::Log;
use Getopt::Long qw(:config auto_help auto_version);
use Pod::Usage;
@@ -189,6 +190,8 @@ pod2usage( -verbose => 2 ) if ($man);
pod2usage( -verbose => 2 ) if ($help and $verbose);
pod2usage(1) if $help;
+cronlogaction();
+
unless ($format) {
$verbose and print STDERR "No format specified, assuming 'text'\n";
$format = 'text';
--- a/misc/cronjobs/serialsUpdate.pl
+++ a/misc/cronjobs/serialsUpdate.pl
@@ -32,6 +32,7 @@ use C4::Context;
use C4::Dates qw/format_date format_date_in_iso/;
use C4::Debug;
use C4::Serials;
+use C4::Log;
use Date::Calc qw/Date_to_Days check_date/;
use Getopt::Long;
@@ -77,6 +78,8 @@ GetOptions(
pod2usage(1) if $help;
pod2usage( -verbose => 2 ) if $man;
+cronlogaction();
+
$verbose and !$confirm and print "### Database will not be modified ###\n";
if ( $note && $nonote ) {
--- a/misc/cronjobs/share_usage_with_koha_community.pl
+++ a/misc/cronjobs/share_usage_with_koha_community.pl
@@ -7,6 +7,7 @@ use Getopt::Long;
use C4::Context;
use C4::UsageStats;
+use C4::Log;
use POSIX qw(strftime);
my ( $help, $verbose, $force );
@@ -30,6 +31,8 @@ If your library wants to share their usage statistics with the Koha community, y
exit 1;
}
+cronlogaction();
+
my $need_update = ($force ? 1 : C4::UsageStats::NeedUpdate() );
if ($need_update) {
--- a/misc/cronjobs/staticfines.pl
+++ a/misc/cronjobs/staticfines.pl
@@ -43,6 +43,7 @@ use C4::Overdues;
use C4::Calendar qw(); # don't need any exports from Calendar
use C4::Biblio;
use C4::Debug; # supplying $debug and $cgi_debug
+use C4::Log;
use Getopt::Long;
use List::MoreUtils qw/none/;
use Koha::DateUtils;
@@ -90,6 +91,8 @@ This script has the following parameters :
ENDUSAGE
die $usage if $help;
+cronlogaction();
+
my $dbh = C4::Context->dbh;
# Processing categories
--- a/misc/cronjobs/update_totalissues.pl
+++ a/misc/cronjobs/update_totalissues.pl
@@ -32,6 +32,7 @@ use Getopt::Long;
use Pod::Usage;
use C4::Context;
use C4::Biblio;
+use C4::Log;
use DateTime;
use DateTime::Format::MySQL;
use Time::HiRes qw/time/;
@@ -94,6 +95,8 @@ if ( not $result or $want_help ) {
usage();
}
+cronlogaction();
+
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
--