D&C GLug - Home Page

[ Date Index ] [ Thread Index ] [ <= Previous by date / thread ] [ Next by date / thread => ]

Re: [LUG] shrinking nohup.out

 

On Wed, 27 Apr 2011, Philip Hudson wrote:

On 27 Apr, 2011, at 11:18 am, tom wrote:

I'm running a job in nohup and wondering how (without stopping the current job) I can empty nohup.out as its getting a bit big but I only want the tail of it...
any clues

http://www.google.com/search?hl=en&q=log+file+%7Erotate&aq=f&aqi=g1g-j6g-b3&aql=t&oq=

Well, you really ought to use this:

  http://lmgtfy.com/?q=log+file+~rotate

However, nohup isn't a log-file producer and you need to know how *nix handles files that are open for writing - and this varies from application to application...

nohup under bash (csh/tsch is different!) opens the file once and appends to it, so renaming or deleting the file won't really do what you want to do - as the file will still be here, hidden and growing, until it's closed, then it will be really deleted and the disk blocks freed...

Dan's solution of echoing nothing into it might work, but I'm not sure if that actually frees up the disk blocks...

But if it does, then

  tail  nohup.out > /tmp/xyzzy ; cp /tmp/xyzzy nohup.out

might work. (use cp, not mv, as cp will overwrite the file and mv will delete it before moving the tail onto it - and that will lose the growing file data)

Gordon

--
The Mailing List for the Devon & Cornwall LUG
http://mailman.dclug.org.uk/listinfo/list
FAQ: http://www.dcglug.org.uk/listfaq