#!/usr/bin/perl -w use warnings; use strict; ############### # CONFIG VARS # ############### my $awhile = 45; # Checking interval (sec) my $my_watched_file = "/cygdrive/c/WATCHDOG/foobar"; my $EMailText= 'To: roboticus@a.fake.domain.com Subject: JobToMonitor.pl fault! Yecch! '; #-------------------------------------------------- # Let watchdog know we're alive... sub still_alive { open OF, '>>', $my_watched_file; print OF $EMailText; close OF; } unlink $my_watched_file; my $next_time = 0; my $count = 0; while ($count < 999999999999) { # put this in a part that's likely to be OK if (time > $next_time) { &still_alive; $next_time = time + $awhile; } # smallish chunks of job that shouldn't take # too much time ++$count; # You can even use it for periodic logging! $EMailText = "$count reached at " . (localtime) . "\n" if $count % 1000000 == 0; } # Don't alert if we complete successfully unlink $my_watched_file;