From 94b157b87122017327a2b9c1410c64ae728309b5 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Sat, 14 Feb 2026 20:29:05 +0000 Subject: [PATCH] Bug 41851: Add logging to edi cron job To test: 1 - Enable cronjob logging: http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=CronjobLog 2 - Enable EDIFACT http://localhost:8081/cgi-bin/koha/admin/preferences.pl?op=search&searchfield=EDIFACT 3 - perl misc/cronjobs/edi_cron.pl 4 - Check action logs for cronjobs: http://localhost:8081/cgi-bin/koha/tools/viewlog.pl?src=&user=&modules=CRONJOBS&actions=&object=&info=&interfaces=&from=&to=&output=screen&basename=Export&report_name=&do_it=1 5 - No log 6 - Apply patch 7 - perl misc/cronjobs/edi_cron.pl 8 - Refresh the action logs screen 9 - Success! Start and end logged Signed-off-by: Nick Clemens --- misc/cronjobs/edi_cron.pl | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/misc/cronjobs/edi_cron.pl b/misc/cronjobs/edi_cron.pl index c3d1954fe6e..8d1dd8c5754 100755 --- a/misc/cronjobs/edi_cron.pl +++ b/misc/cronjobs/edi_cron.pl @@ -36,10 +36,14 @@ use Koha::EDI qw( process_quote process_invoice process_ordrsp ); use Koha::Edifact::Transport; use Koha::Logger; use Koha::Plugins::Handler; -use Fcntl qw( LOCK_EX O_CREAT O_RDWR SEEK_SET ); +use Fcntl qw( LOCK_EX O_CREAT O_RDWR SEEK_SET ); +use C4::Log qw( cronlogaction ); die "Syspref 'EDIFACT' is disabled" unless C4::Context->preference('EDIFACT'); +my $command_line_options = join( " ", @ARGV ); +cronlogaction( { info => $command_line_options } ); + # we dont have a lock dir in context so use the logdir my $logdir = C4::Context->config('logdir'); my $pidfile = "$logdir/edicron.pid"; @@ -150,6 +154,8 @@ if ( close $pid_handle ) { exit 1; } +cronlogaction( { action => 'End', info => "COMPLETED" } ); + sub check_pidfile { # sysopen my $fh, $pidfile, O_EXCL | O_RDWR or log_exit "$0 already running" -- 2.39.5