lr_config/lr_cron errors

Wolfgang Sourdeau Wolfgang at logreport.org
Wed Mar 10 09:57:53 CET 2004


Thank you for reporting that problem. To my knowledge you are the first
person to report it.

Please rebuild your installation of lire with this new version of
lr_cron.in put in <lire_dir>/all/scripts/.


Wolfgang
-------------- next part --------------
#! @PERL@ -w

# vim:syntax=perl

use strict;

use lib '@LR_PERL5LIBDIR@';

use Carp;
use Lire::Config;
use Lire::Utils qw(min max tilde_expand);
use Lire::Config::Build qw(ac_info ac_path);
use Lire::DlfConverterManager;

my $conf = Lire::Config::instance();
$conf->init();

my $mgr = Lire::DlfConverterManager->instance();
$mgr->register_default_converters();

croak "Usage: $0 <hourly|daily|weekly|monthly|yearly>"
    unless @ARGV == 1 && $ARGV[0] =~ /^(hourly|daily|weekly|monthly|yearly)$/i;

my $period = lc $ARGV[0];

my @files = $conf->config_files;
my %jobs;

sub sanitize {
    s![^A-Za-z0-9_.,+/@%:-]!\\$&!g
        foreach(@_);
}

foreach my $filename (@files) {
    my $file = $conf->get_config_file($filename);
    @jobs{$file->job_names} = ();
}

foreach my $jobname (keys %jobs) {
    $conf->set_job_id($jobname);

    my $per = $conf->get('lr_period');
    next unless defined $per;
    next unless lc $per eq $period;

    my $service = $conf->get('lr_service');
    unless(defined $service) {
        carp "No service name specified for cron job $jobname";
        next;
    }
    my $log = $conf->get('log_file');
    unless(defined $log) {
        carp "No log file specified for cron job $jobname";
        next;
    }
    my $to = $conf->get('lr_mail_to');
    $to = 'root'
        unless defined $to;
    my $subject = $conf->get('lr_mail_subject');
    $subject = "Lire job '$jobname'"
        unless defined $subject;

    sanitize($service, $log, $to, $subject);

    my $filter = $conf->get('log_file');
    if(defined $filter) {
        sanitize($filter);
        system("lr_run $filter < $log | lr_run lr_log2mail -s $subject $service $to");
    } else {
        system("lr_run lr_log2mail -s $subject $service $to < $log");
    }
}

__END__

=pod

=head1 NAME

lr_cron - run periodical Lire jobs

=head1 SYNOPSIS

B<lr_cron> I<period>

=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".

lr_config(1) can be run to configure B<lr_cron>.

=head1 SEE ALSO

lr_log2mail(1), lr_run(1), lr_config(1)

=head1 VERSION

$Id: lr_cron.in,v 1.20 2004/03/10 01:31:57 wsourdeau Exp $

=head1 COPYRIGHT

Copyright (C) 2000, 2001, 2002, 2003 Stichting LogReport Foundation
LogReport at 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 or write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.

=head1 AUTHOR

Joost van Baal <joostvb at logreport.org>, reimplemented in Perl by Wessel Dankers
<wsl at logreport.org>

=cut

Local Variables:
mode: cperl
End:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 249 bytes
Desc: not available
Url : http://lists.logreport.org/pipermail/questions/attachments/20040310/c5b49c13/attachment.bin 


More information about the Questions mailing list