Re: Question about nohup

From: Barry Margolin (barmar_at_alum.mit.edu)
Date: 03/13/04

  • Next message: Michael Tosch: "Re: Sparc5 Sol 8 Apache 2.0.48 ?"
    Date: Sat, 13 Mar 2004 14:34:17 -0500
    
    

    In article <c2ufp7$22819u$1@ID-159130.news.uni-berlin.de>,
     Madhusudan Singh <spammers-go-here@yahoo.com> wrote:

    > Hi
    >
    > I regularly use nohup to start computation intensive jobs on remote
    > Sun
    > machines. Usually this creates a file named "nohup.out" in the working
    > directory that contains the o/p that would have occured on the terminal had
    > the program been run without nohup.
    >
    >
    > I have noticed that sometimes, upon completion of the process, the
    > file
    > nohup.out does not contain anything. There is plenty of space on the disk,
    > but it would not form. Now, I have seen this behaviour before, but ignored
    > it as it did not matter. Lately, a few processes of mine have been crashing
    > mysteriously and I do need to see at which point the process crashed.
    > Absent nohup.out, there does not seem to be a way.

    If the program uses stdio, it defaults to full buffering of stdout
    whenever it's connected to something other than a terminal. If the
    program crashes before it has produced enough output to fill the buffer
    (which I think tends to be about 4KB on many systems), the buffer will
    not be flushed to the file.

    >
    > I have looked at the man page, and there do not seem to be any
    > options that
    > would force nohup to dump the console o/p from whatever it was running. Is
    > redirecting terminal o/p to another file, the only way to get the
    > information ? (like nohup process 2>processlog.txt & ) ?

    If my assumption above is correct, the problem is with stdout, not
    stderr. By default, stderr is unbuffered, so it doesn't suffer from the
    problem I described. Your command here redirects stderr, not stdout.

    Anyway, doing the redirection explicitly doesn't change the problem --
    it's still going to a file instead of a terminal, so it's still going to
    be buffered.

    The Expect scripting language comes with an "unbuffer" script that makes
    use of a pseudo-tty to prevent this buffering. Or if you can modify the
    program's source code, you can use setbuf() to disable buffering of
    stdout.

    -- 
    Barry Margolin, barmar@alum.mit.edu
    Arlington, MA
    *** PLEASE post questions in newsgroups, not directly to me ***
    

  • Next message: Michael Tosch: "Re: Sparc5 Sol 8 Apache 2.0.48 ?"

    Relevant Pages

    • Re: Perl 5.8.x, Unicode and In-memory Filehandles
      ... I have just started out experimenting the Unicode capabilities of Perl. ... output buffering with Perl's openin-memory filehandles, ... # Content verified; commit to real STDOUT ... request header) indicates he prefers Big5, ...
      (comp.lang.perl.misc)
    • Re: Using nCurses Inside Existing Program
      ... Before nCurses is instantiated, it is not necessary to flush stdout. ... ncurses change ... the buffering of stdout to block-buffering. ...
      (comp.unix.programmer)
    • Re: order of execution
      ... stdout and stderr are different streams. ... the standard error stream is not fully buffered; ... C defines three buffering modes for streams: ...
      (comp.lang.c)
    • Re: Complicated macro...
      ... Just out of curiousity, why is stdout buffering ... Even in situations like this it usually isn't necessary to flush after ... every output operation. ...
      (comp.lang.c)
    • Perl 5.8.x, Unicode and In-memory Filehandles
      ... I have just started out experimenting the Unicode capabilities of Perl. ... output buffering with Perl's openin-memory filehandles, ... # Content verified; commit to real STDOUT ... request header) indicates he prefers Big5, ...
      (comp.lang.perl.misc)