/usr/bin/lr_cron is in lire 2:2.1.1-2.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | #! /usr/bin/perl -w
# vim:syntax=perl
use strict;
use lib '/usr/share/perl5';
use Locale::TextDomain qw/lire/;
use Lire::Config;
use Lire::Error qw/ an_error_occured missing_argument_usage /;
use Lire::PluginManager;
use Lire::DlfStore;
Lire::Config->init();
Lire::PluginManager->register_default_plugins();
my ( $period, $store_path, $time ) = @ARGV;
my $usage = __( "Usage: lr_cron <period> <store>\n" );
die ( missing_argument_usage( 'period' ),
$usage )
unless defined $period;
die ( __x( "Invalid period '{period}'. Should be one of hourly, daily, weekly, monthly or yearly.\n", 'period' => $period ),
$usage )
unless $period =~ /^(hourly|daily|weekly|monthly|yearly)$/;
die ( missing_argument_usage( 'store' ),
$usage )
unless defined $store_path;
# Since lr_cron is run once the period is over, we need to
# offset it.
$time ||= time();
if ( $period eq 'hourly' ) {
$time -= 3600;
} else {
$time -= 86400;
}
eval {
my $store = Lire::DlfStore->open( $store_path, 1 );
foreach my $job ( @{ $store->import_jobs() } ) {
$job->run( $store, $time ) if $job->period() eq $period;
}
foreach my $job ( @{ $store->report_jobs() } ) {
$job->run( $store, $period, $time );
}
$store->clean_streams( $time )
if $period eq 'daily';
$store->close();
};
die an_error_occured( $@ ) if $@;
exit( 0 );
__END__
=pod
=head1 NAME
lr_cron - run the perodical jobs configured in a DlfStore.
=head1 SYNOPSIS
B<lr_cron> I<period> I<store>
=head1 DESCRIPTION
B<lr_cron> is designed to be called in a crontab(5) entry.
I<period> should be "hourly", "daily", "weekly", "monthly" or "yearly".
I<store> should be the full path name of the DLF Store.
lire(1) should be used to configure periodical jobs in the store.
To run jobs as scheduled by lire(1), you will need to setup cron jobs. For each
schedule you use, you should configure a cron job to be executed according to
that period.
Here is a crontab(5) entry that will make sure that all possible
schedules are supported in the /home/flacoste/myStore DLF store:
05 * * * * lr_run lr_cron hourly /home/flacoste/myStore
15 01 * * * lr_run lr_cron daily /home/flacoste/myStore
15 02 * * 02 lr_run lr_cron weekly /home/flacoste/myStore
15 03 01 * * lr_run lr_cron monthly /home/flacoste/myStore
15 04 01 01 * lr_run lr_cron yearly /home/flacoste/myStore
.
=head1 SEE ALSO
lire(1)
=head1 AUTHOR
Francis J. Lacoste <flacoste@logreport.org>
=head1 VERSION
$Id: lr_cron.in,v 1.37 2006/07/23 13:16:32 vanbaal Exp $
=head1 COPYRIGHT
Copyright (C) 2004 Stichting LogReport Foundation
LogReport@LogReport.org
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program (see COPYING); if not, check with
http://www.gnu.org/copyleft/gpl.html.
=cut
Local Variables:
mode: cperl
End:
|