+ # read in any changes if the modification time has changed
+ init();
+
+ $mon += 1; # months otherwise go 0-11
+ my $cron;
+ foreach $cron (@crontab) {
+ if ((!$cron->{min} || grep $_ eq $min, @{$cron->{min}}) &&
+ (!$cron->{hour} || grep $_ eq $hour, @{$cron->{hour}}) &&
+ (!$cron->{mday} || grep $_ eq $mday, @{$cron->{mday}}) &&
+ (!$cron->{mon} || grep $_ eq $mon, @{$cron->{mon}}) &&
+ (!$cron->{wday} || grep $_ eq $wday, @{$cron->{wday}}) ){
+
+ if ($cron->{cmd}) {
+ dbg('cron', "cron: $min $hour $mday $mon $wday -> doing '$cron->{cmd}'");
+ eval "$cron->{cmd}";
+ dbg('cron', "cron: cmd error $@") if $@;
+ }
+ }
+ }
+ }
+
+ # remember when we are now
+ $lasttime = $now;
+ $lastmin = $min;
+}
+
+#
+# these are simple stub functions to make connecting easy in DXCron contexts
+#
+
+sub connected
+{
+ my $call = uc shift;
+ return DXChannel->get($call);
+}
+
+sub start_connect
+{
+ my $call = uc shift;
+ my $lccall = lc $call;
+
+ my $prog = "$main::root/local/client.pl";
+ $prog = "$main::root/perl/client.pl" if ! -e $prog;
+
+ my $pid = fork();
+ if (defined $pid) {
+ if (!$pid) {
+ # in child, unset warnings, disable debugging and general clean up from us
+ $^W = 0;
+ eval "{ package DB; sub DB {} }";
+ $SIG{HUP} = 'IGNORE';
+ alarm(0);
+ DXChannel::closeall();
+ $SIG{CHLD} = $SIG{TERM} = $SIG{INT} = $SIG{__WARN__} = 'DEFAULT';
+ exec $prog, $call, 'connect';
+ dbg('cron', "exec '$prog' failed $!");
+ }
+ dbg('cron', "connect to $call started");
+ } else {
+ dbg('cron', "can't fork for $prog $!");