nohup.out

I have a program which writes to nohup.out ...
over the time this nohup.out becomes a large file and i cannot read the contents of this file using a vi editor.... whe i do a vi nohup.out it gives an error insufficient memory....
do i need to clean this nohup.out periodically ( or compress it using tar and place it as an archived file) how to clean this nohup.out. or how to look into the contents of this nohup.out

Anybody who came across a similar problem pls respond.

thanks n Happy NEW YEAR.
Ram

The reason you cannot open the file with VI is the file is to large for VI to handle. You could look at the file using tail or more. The file is created by a background process running with nohup (No Hang Up) protection and the contents of the nohup.out is the output from the processes. First check the contents of the file and if safe just cat /dev/null to to clear it.

thank you...

Hi..,
Related to this issue, is there a way to limit the size of nohup.out file automatically?

rgds,
Ollie

Yes, there is: put a cron-job in effect, which truncates the file (by something like "cat /dev/null > nohup.out"). How often you will have to run this job depends on how much output your process generates.

But if you do not need the output of the job altogether (maybe its garbage anyways, only you can answer that) you could prevent writig to file nohup.out in first place. Right now you start the process in a way like this:

nohup command &

replace this by

nohup command 2>/dev/null 1>/dev/null &

and the file nohup.out won't even get created.

The reason why the output of the process is being directed to a file is:

Normally all processes (that is: commands you enter from commandline, there are exceptions, but they don't matter here) are attached to a terminal. Per default (this is how Unix is handling this) this is something which can display text and is connect to the host via a serial line. If you enter a command and switch off the terminal you entered it from the process gets terminated too - because it lost its terminal. Because in serial communication the technicians traditionally employed the words from telephone communication (where it came from) the termination of a communication was not called an "interruption" or "termination" but a "hangup". So programs got terminated on "hangups" and to program to prevent this was "nohup", the "no-termination-upon-hangup"-program.

But as it may well be that such an orphaned process has no terminal to write to it nohup uses the file nohup.out as a "screen-replacement", redirecting the output there, which would normally go to the screen. If a command has no output whatsoever though nohp.out won't get created.

bakunin

Thanks for the reply..

Just noticed that it is an AIX forum, I hope the answer is valid in HPUX (and others) too..

Thanks Bakunin
Hope to see you on the Bridge table :smiley:

BBO: OllieBond