in reply to Re^2: How to make PERL Script run Automaticly?
in thread How to make PERL Script run Automaticly?

good point Laurent, thanks! For now, it is not of that matter, because I timed it that the script needs 10minutes to run. Later on, this will come into matter, as the script will grow larger.

Just to clearify it for myself: So if I run the above code once in Linux .. it will continue running until I close the Linux client, right?

  • Comment on Re^3: How to make PERL Script run Automaticly?

Replies are listed 'Best First'.
Re^4: How to make PERL Script run Automaticly?
by AppleFritter (Vicar) on Jul 04, 2014 at 10:03 UTC

    For now, it is not of that matter, because I timed it that the script needs 10minutes to run. Later on, this will come into matter, as the script will grow larger.

    You could time the function call:

    while(1) { my $startingtime = time; expensive_function(); sleep $startingtime - time() + 7200; }

    This may still introduce drift over time as time only has a granularity of one second, though.

    In any case, using cron (as suggested above) is definitely the right thing to do. Just ask your friendly local sysadmin.

Re^4: How to make PERL Script run Automaticly?
by Laurent_R (Canon) on Jul 04, 2014 at 08:36 UTC
    Yes it will run "forever", i.e. until you kill it, switch off the machine or something else goes wrong. Make sure that you don't have a memory leak (although this is relatively uncommon in Perl), because if you do have one, your program is doomed to fail sooner or later.