From d97dcf91d4bd3b8d3c31e5aafa439d00ba31066c Mon Sep 17 00:00:00 2001 From: Dirk Koopman Date: Fri, 24 Apr 2020 13:13:45 +0100 Subject: [PATCH] fix default crontab --- cmd/crontab | 2 +- perl/DXCron.pm | 23 ++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/cmd/crontab b/cmd/crontab index ac62bd30..c6b1da26 100644 --- a/cmd/crontab +++ b/cmd/crontab @@ -6,5 +6,5 @@ # for doing connections and things # 2 0 * * * DXDebug::dbgclean() -2 30 * * 3 DXUser::export() +30 2 * * * run_cmd("export_users") 0 3 * * * Spot::daily() diff --git a/perl/DXCron.pm b/perl/DXCron.pm index 0d425c75..13379197 100644 --- a/perl/DXCron.pm +++ b/perl/DXCron.pm @@ -73,17 +73,18 @@ sub cread my $ref = bless {}; my $err; - $err |= parse($ref, 'min', $min, 0, 60); - $err |= parse($ref, 'hour', $hour, 0, 23); - $err |= parse($ref, 'mday', $mday, 1, 31); - $err |= parse($ref, 'month', $month, 1, 12, "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"); - $err |= parse($ref, 'wday', $wday, 0, 6, "sun", "mon", "tue", "wed", "thu", "fri", "sat"); + $err .= parse($ref, 'min', $min, 0, 60); + $err .= parse($ref, 'hour', $hour, 0, 23); + $err .= parse($ref, 'mday', $mday, 1, 31); + $err .= parse($ref, 'month', $month, 1, 12, "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec"); + $err .= parse($ref, 'wday', $wday, 0, 6, "sun", "mon", "tue", "wed", "thu", "fri", "sat"); if (!$err) { $ref->{cmd} = $cmd; push @out, $ref; dbg("DXCron::cread: adding $_\n") if isdbg('cron'); } else { - dbg("DXCron::cread: error on line $line '$_'\n") if isdbg('cron'); + $err =~ s/^, //; + dbg("DXCron::cread: error $err on line $line '$_'\n") if isdbg('cron'); } } close($fh); @@ -102,7 +103,7 @@ sub parse # handle '*' values if ($val eq '*') { $ref->{$sort} = 0; - return 0; + return; } # handle comma delimited values @@ -110,20 +111,20 @@ sub parse for (@comma) { my @minus = split /-/o; if (@minus == 2) { - return 1 if $minus[0] < $low || $minus[0] > $high; - return 1 if $minus[1] < $low || $minus[1] > $high; + return ", $sort should be $low >= $minus[0] <= $high" if $minus[0] < $low || $minus[0] > $high; + return ", $sort should be $low >= $minus[1] <= $high" if $minus[1] < $low || $minus[1] > $high; my $i; for ($i = $minus[0]; $i <= $minus[1]; ++$i) { push @req, 0 + $i; } } else { - return 1 if $_ < $low || $_ > $high; + return ", $sort should be $low >= $val <= $high" if $_ < $low || $_ > $high; push @req, 0 + $_; } } $ref->{$sort} = \@req; - return 0; + return; } # process the cronjobs -- 2.43.0