in reply to Problem with switching log files

So what's your problem? What isn't working?

Replies are listed 'Best First'.
Re^2: Problem with switching log files
by ice_ice_ice (Initiate) on Dec 27, 2011 at 19:20 UTC
    I don't know why is not working ;)

    I had a error: Unable to open logfile:Permission denied

    I'm working as a root so I should have permission to create any file

      I'm working as a root so I should have permission to create any file

      That is simply not true. There are a number of possibilities that can prevent even root to write to a file (or create it):

      • file is readonly
      • directory if readonly
      • filesystem is readonly (for example CDROM)
      • out of filehandles
      • out of memory
      • disk full
      • file system errors that implicitly make the filesystem readonly
      • file locked by another program
      • directory locked by another program (most likely kernel during some directory move operations)
      • file on a network filesystem where you don't have permissions
      • Some "virtual" files can't be written to (/proc/*)
      • ...The list goes on and on and on to ever more obscure "error" conditions...

      BREW /very/strong/coffee HTTP/1.1
      Host: goodmorning.example.com
      
      418 I'm a teapot
      I can open the first log file, but with next file I have a problem:(
        This is working on my pc.
        use strict; use warnings; my($NEXT_TIME,$FILE_NUMBER,$LOG_FILE); $NEXT_TIME=time; $FILE_NUMBER=0; while(1){ if ( time > $NEXT_TIME ) { print "Change file next=$NEXT_TIME\n"; thread_log(); } } sub thread_log { #closing the handler to the current file if ( -e "log$FILE_NUMBER.log" ) { close($LOG_FILE); } $FILE_NUMBER += 1; open( $LOG_FILE, '>', "log$FILE_NUMBER.log" ) or die "Unable to open logfile:$!\n"; $NEXT_TIME = $NEXT_TIME + 10; }
        It seems the problem is in other place. How you invoke threads?