Remove the nohup.out file

Harish T asked:

Whether it will create issues if we are removing the nohup.out file during the application execution on redhat server?

The file size was getting increased in our production machine, hence i deleted file of nohup.out

Then same time the application was stopped working, is it related to nohup.out file.

My answer:


Yes, it will create an issue.

The file will continue to exist on disk as long as any process has it open. When you delete it, the directory entry pointing to the file is deleted and its reference count is reduced. But since some process already had the file open, the reference count is 2, not 1, and is decremented to 1, not 0.

After the process writing to the file closes the file (usually when it exits), then the file’s reference count will finally reach 0 and it will actually be deleted.

In the meantime, the file will continue to consume additional disk space as it is written to.

If you don’t wish to have this file at all, you can simply redirect its output to /dev/null, and none of its output will be saved anywhere, e.g.:

nohup <process> >/dev/null

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.