our $startTime = time(); # put this line BEFORE use Win32::Daemon; ... ... ... our $t; sub Callback_Running { my ($Event, $Context) = @_; $t = $startTime if ! $t; if (SERVICE_RUNNING == Win32::Daemon::State()) { if (time() - $t >= $iSleep * 60) { print $fh "Checking in.\n"; # Do work here $t = time(); } # These two lines are needed for both versions $Context->{last_state} = SERVICE_RUNNING; Win32::Daemon::State( SERVICE_RUNNING ); } elsif (SERVICE_PAUSED == Win32::Daemon::State()) { # Without this, pause/continue fails $Context->{last_state} = SERVICE_PAUSED; Win32::Daemon::State( SERVICE_PAUSED ); } }