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

Is there a way to make a script execute every 30 minutes

Replies are listed 'Best First'.
Re: Reloading
by ehdonhon (Curate) on Jun 28, 2002 at 13:48 UTC
    Yes, but this really isn't a Perl question. You need to go learn how to use crontab.
Re: Reloading
by sschneid (Deacon) on Jun 28, 2002 at 13:50 UTC
    If you're on a *NIX box, take a look at cron (man cron)...
    NAME cron - clock daemon SYNOPSIS /usr/sbin/cron DESCRIPTION The cron command starts a process that executes commands at specified dates and times. Regularly scheduled commands can be specified according to instructions found in crontab files in the directory /var/spool/cron/crontabs. Users can submit their own crontab file using the crontab(1) command. Commands which are to be executed only once may be submitted using the at(1) command.
    I'm sure there is a similar function under Win32, but unfortunately I have no idea what it would be. Something I've found useful for reloading scripts while they're still running (it leaves zombie processes, but it works for a quick hack. If anyone can suggest something better, I'd be interested in knowing!)
    if ($cmd eq 'reload') { my $child = fork (); if ($child) { print "Reloading...\n"; exec ('perl script.pl'); exit 1; } else { exit 1; } }
    And if you're interested in reloading libraries, you may want to take a look at this node.

    Hope it helps somewhat.

    scott.

    Edited: added line about reloading libraries.
Re: Reloading
by moxliukas (Curate) on Jun 28, 2002 at 13:47 UTC
    well, something like this could help:
    sub foo { print "bar\n"; } while(1) { foo(); sleep(30); }
    This will execute function foo every 30 seconds. I am aware that you might be looking for something else, but hope this helps too.
Re: Reloading
by Anonymous Monk on Jun 28, 2002 at 13:49 UTC
    hmmm how would I make a password generator so the password would change every 30 minutes.