in reply to Daemon problem with sleep()

It might be just a buffering problem. Are you sure you have waited long enough for the IO buffer (typically around 4k) to fill up?

Try flushing:

use IO::Handle; ... while (1) { print LOG "before sleep..."; LOG->flush(); sleep(1); print LOG "after sleep..."; }

(Also see Re: Troubles with do...while loop and sleep (line- vs. block-buffered) — or the classic "Suffering from Buffering")

(Update: moved LOG->flush() before the sleep — thanks ikegami)

Replies are listed 'Best First'.
Re^2: Daemon problem with sleep()
by MichaelMeyer (Novice) on Dec 17, 2008 at 12:38 UTC
    Hi almut, you were right, it was a buffering problem with explicit flushing now it works. Thanks for the help!
      Even after proper flushing, don't forget to rotate your log file properly using log4perl or log::agent modules, otherwise your log file may reach the maximum allowed file size by the OS and soon it may lead to catastrophic situations.