ahmad has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

i'm trying to make a script that run in the background

how it could be accomplished ?

code sample

#!/usr/bin/perl -w use strict; # Delay in minutes (minutes * 60) my $INTERVAL = 30 * 60; open(STDERR,">logs.txt"); print STDERR "LOG started at : " . localtime(time) . "\n"; select STDERR; while (1) { sleep($INTERVAL); &check_logs; } sub check_logs { # some logs checking goes here then print out the output print STDERR "Logs Processed found : ???? at ????\n"; }

Replies are listed 'Best First'.
Re: WinXP running script in the background
by zentara (Cardinal) on May 10, 2006 at 16:04 UTC

      Thanks ,

      I tryed those ways but i dont know why my script dies when i close the "CMD" window

      What i want is to be able to close the (MS DOS) window after executing the script and keep the script working in the background

      Code examples will help much

        Well it sounds like you want your script to act like a service (in Windows terminology) or Daemon (*nix terminology).

        In that case, check out Win32::Daemon.

        Good luck,

        Trix

        You might want to look at Scheduled Tasks and wperl