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

Hello,

I am knew to scripting.. so this may actually be a very simple question. I have a script which I would like to run every night at the same time. How do I do that without having to manually start up a new instance of the script every night? Also if there is a sudden network failure or something I want it to recognize this, and restart at it's next available time (sometimes our network drives unmap during a power failure too...).

With regards to the network failure, if the network dies when it's unzipping something (like with bunzip2), I want it to flag that and move onto another file rather then process it again, because the file will likely be corrupted.

Any help would be appreciated!

THANKS!

Replies are listed 'Best First'.
Re: Automatically running a script
by JavaFan (Canon) on Nov 02, 2009 at 19:38 UTC
    I would use cron if I were using a UNIX or UNIX like system. (man cron).
      And for those who have to work with Win, "Scheduled task" from the control panel usually does an OK job.
Re: Automatically running a script
by markkawika (Monk) on Nov 02, 2009 at 20:24 UTC

    With regards to the network dying when it's unzipping something, typically if you're calling an external program such as bunzip2 to uncompress a file, and the network dies partway through the uncompression process, the bunzip2 process itself will return with an error code.

    If you just make sure to check the return status of the uncompression program you'll be able to detect it and re-try the uncompression later.