Monday, March 24, 2014

Truncate running nohup.out file in Unix

Truncate running nohup.out file in Unix
Sometimes because of faulty logger implementations or a process which is running for a long time in Unix
Operating System, background console output file “nohup.out” continues to grow in size and finally we need
to restart the process to either remove this or truncate this.

The below command will empty the “nohup.out” file without impacting running process:


UNIX_SHELL$   >   nohup.out


Or

UNIX_SHELL$  cat   /dev/null   >   nohup.out

2 comments:

  1. I've tried this method to clear content of nohup.out file and it kind of working, because i checked the filesystem size allocation by 'df -h' command and shows that it cleaned and freed more spaces, but in fact the filesize itself showing 162G of nohup.out
    How can i fix it? if it's not actual 162G why it keeps showing such a large filesize? Thank you in advance

    ReplyDelete
    Replies
    1. Did you check "du -sh nohup.out" command. This will say you exact space. But either way file size should not show 162G. I keep using this command and it never failed on expectation. May be it is taking some time to clear the size.

      Delete