in reply to Perl daemon ?

hi,

to make a simple daemon just de-attach the called script with this peace of code:

die "Cannot continue :$!" unless(defined(my $kid = fork())); unless ($kid){ system("my scheduler"); exit; }
and now when you demonize your script then you can with a simple while loop schedule all scripts set in some dir like:
in my scheduler : ----------------- while(1){ # predefined diractory opendir(DIR,"some dir") || die "$!"; foreach my $sc (readdir(DIR)){ next if ($sc=~/\./g); system($sc); } sleep 3600; # of whatever time you need }
and that is more-or-less what you need to set up your first crone-like application. (just remember to set the absolute path with readdir -> it just captures the names of scripts in opened folder). of course don't forget to chmod to 555 to all files in defined dir (either through perl or manually).

good luck !

Replies are listed 'Best First'.
Re^2: Perl daemon ?
by newbie01.perl (Sexton) on Nov 23, 2009 at 10:26 UTC

    Hi,

    I think this is more or less what I wanted. I found some example that uses fork as well but not sure whether that will actually make any difference.

    Also found a Daemon.pm, but not to sure on how to use it.