HouseKeepingCron — define Interchange-aware crontab entries
HouseKeepingCron
is an Interchange-equivalent of the usual Unix "cron"
(periodic execution) facility.
Time specifications (first six fields) behave exactly like
with the traditional Vixie cron.
That includes numbers, ranges and '*
';
see crontab(5) manual page.
Additional features are provided by the Set::Crontab
Perl module:
The '<
' and
'N
>
' select
elements smaller and larger than N
N
.
!
excludes
N
N
from the set. "!3
"
with a range of "1-10
" corresponds to
"1-2,4-10
", and ">3,!7
"
in the same range means "4-6,8-10
".
Target specification, provided in form of everything after the 6th field,
consists of the catalog name and action. Catalog name can be prefixed
with >
, <
and
=
.
Name prepended with '>
' will make the
commands run after the
reconfig/restart/jobs/pid management cycle (usually they run before).
Interchange-specific things you can run include
everything you can put into execution over
Vend::Dispatch::run_macro
function.
That means GlobalSub
s, Sub
s and anything
else that is suitable for interpolation (all ITL code).
Bear in mind, though, that there is no catalog context; everything is executing on the global level.
In addition to the above, two special targets exist,
:reconfig
and :jobs
.
They define the intervals for processing
catalog reconfiguration and batch job requests.
The reconfig
and
jobsqueue
files in RunDir
are ignored
if HouseKeepingCron
is specified and these targets not included.
In that case, a warning will be issued because, without the two
entries, catalog reconfiguration or job execution requests are
ignored — something you almost never want in regular operation.
Example: Running :restart and :jobs every 5 minutes
The basic entry to implement HouseKeeping 300
would be:
HouseKeeping 1 minute HouseKeepingCron <<EOC */5 * * * * * :restart */5 * * * * * :jobs EOC
Example: Running batch jobs
HouseKeepingCron <<EOC 0 0 * * * * =standard hourly 0 1 2 * * * =standard daily 0 2 4 * * 7 =standard weekly 0 0 3 1 * * =standard monthly EOC
Example: Warning message when :reconfig entry is not present
The warning message would look like this:
WARNING: suggested cron entry ':reconfig' not present.
Interchange 5.9.0:
Source: lib/Vend/Config.pm
Line 4129 (context shows lines 4129-4144)
sub parse_cron { my($var, $value) = @_; return '' unless $value =~ /\s/ and $value =~ /[a-zA-Z]/; unless($Vend::Cron::Loaded) { config_warn( "Cannot use %s unless %s module loaded%s", 'crontab', 'Vend::Cron', ' (missing Set::Crontab?)', ); return ''; } return Vend::Cron::read_cron($value); }