Bug 31203: Alter other cronjobs that currenlty use cronlogaction
[koha.git] / misc / cronjobs / plugins_nightly.pl
1 #!/usr/bin/perl
2
3 use Modern::Perl;
4
5 use Try::Tiny qw( catch try );
6
7 use C4::Context;
8 use C4::Log qw( cronlogaction );
9 use Koha::Logger;
10 use Koha::Plugins;
11 use Koha::Script -cron;
12
13 my $command_line_options = join(" ",@ARGV);
14 cronlogaction({ info => $command_line_options });
15
16 my $logger = Koha::Logger->get();
17 if ( C4::Context->config("enable_plugins") ) {
18     my @plugins = Koha::Plugins->new->GetPlugins(
19         {
20             method => 'cronjob_nightly',
21         }
22     );
23
24     foreach my $plugin (@plugins) {
25         try {
26             $plugin->cronjob_nightly();
27         }
28         catch {
29             warn "$_";
30             $logger->warn("$_");
31         };
32     }
33 }
34
35 cronlogaction({ action => 'End', info => "COMPLETED" });
36
37 =head1 NAME
38
39 plugins_nightly.pl - Run nightly tasks specified by plugins
40
41 =head1 SYNOPSIS
42
43 plugins_nightly.pl
44
45 =head1 AUTHOR
46
47 Martin Renvoize <martin.renvoize@ptfs-europe.com>
48
49 =head1 LICENSE
50
51 This file is part of Koha.
52
53 Koha is free software; you can redistribute it and/or modify it
54 under the terms of the GNU General Public License as published by
55 the Free Software Foundation; either version 3 of the License, or
56 (at your option) any later version.
57
58 Koha is distributed in the hope that it will be useful, but
59 WITHOUT ANY WARRANTY; without even the implied warranty of
60 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61 GNU General Public License for more details.
62
63 You should have received a copy of the GNU General Public License
64 along with Koha; if not, see <http://www.gnu.org/licenses>.
65
66 =cut