in reply to Tracking actual time spent sleeping: Is this bad coding?

I don't see a huge issue with that. You could improve it by changing the sleep(60) to sleep( $Interval - $slept + 1 ).

But, that begs the question - why aren't you using your system's version of cron?

Being right, does not endow the right to be rude; politeness costs nothing.
Being unknowing, is not the same as being stupid.
Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

  • Comment on Re: Tracking actual time spent sleeping: Is this bad coding?

Replies are listed 'Best First'.
Re^2: Tracking actual time spent sleeping: Is this bad coding?
by Random_Walk (Prior) on Feb 02, 2005 at 15:21 UTC

    Dunno about the OP but I have a daemonized process that monitors some hardware and sleeps a lot. I do not use cron though because the start up costs are high compared to the actual work it does.

    Cheers,
    R.

    Pereant, qui ante nos nostra dixerunt!
      If you're worried about the startup costs of cron, I've had excellent experiences with Schedule::Cron. You can daemonize the process and tell it to run a coderef on schedule.
      I'm unfamiliar with any start-up costs of cron. I use it quite frequently on most boxes I administer. Would you mind going into detail? Perhaps after your explanation I'll change my ways.

      - Justin

        Hi jpk236,

        It is not a cost of cron but the costs of starting my process that is high. My Process has to load and compile about 700 regular expressions each time it starts. Why do this every N minutes when you can do it once and hold the results in memory ?

        I do like the look of Schedule::Cron and it looks like it would provide a nice solution to the OP's problem, friedo++

        Cheers,
        R.

        Pereant, qui ante nos nostra dixerunt!

        There are no start-up costs with cron itself. The start-up costs referred to in this thread are associated with the Perl code and would be the same whether the program is ran from cron or from the command line (e.g compiling modules, connecting to databases etc).

        -- vek --