in reply to Perl script to run for x hours

Hi t-rex,

The best way to do that can vary depending on what the script is doing. Is it doing heavy calculations, reading from a file, network communication, ...?

Also, see Alternatives to Mixing Alarm and Sleep.

Regards,
-- Hauke D

Replies are listed 'Best First'.
Re^2: Perl script to run for x hours
by t-rex (Scribe) on Sep 28, 2016 at 17:03 UTC

    hello,

    yes its doing heavy processing , sockets,file transfers, running some tools

      Hi t-rex,

      For things under your control (calculations, reading a file), you can implement the timeout yourself (e.g. marinersk gave a basic example). For network communication, you can usually specify timeouts after which the control will return to your script, at which point you can do your own timeout checks. For external processes, it really depends on the external process. You'll have to be a lot more specific in your question, otherwise the best we can do is general suggestions. I know what I mean. Why don't you? and How do I post a question effectively?

      Regards,
      -- Hauke D