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