Discussion:
Rotating nohup.out without stopping the app
(too old to reply)
igor
2004-07-07 23:17:41 UTC
Permalink
I am looking for ideas on how to solve a problem with a nohup.out file
that is growing faster than expected.

While we change to a better logging mechanism we're using the stdout
to dump a bunch of debugging messages (a bunch is actually a lot!!).
Any hows, when the application runs for a few days the nohup.out file
could be 1G in size and to search for something on that file becomes a
pain in the neck.

The way I am doing that is pretty much manually. Stop the app, move
the file out and restart the app (using nohup).

I don't know if any of you guys know a better way to either rotate the
nohup.out (by date or size, don't care) or to redirect the stdout to a
logging application.

I have been looking around in the groups and on the net but can't find
anything that will give me some lights on how to do it.

Ciao,
Igor
Kasper Dupont
2004-07-09 15:17:34 UTC
Permalink
Post by igor
I don't know if any of you guys know a better way to either rotate the
nohup.out (by date or size, don't care) or to redirect the stdout to a
logging application.
The way nohup works it is impossible to rotate the
output file. It is not nohup that is writing to the
file. It just opens the file and exec the program.
By the time you want to rotate the file nohup is no
longer running. So support for rotation would have
to be in the program, which is a bad idea as the
program should not have to worry where its stdout
goes.

It shouldn't take much work to write a program, that
will read stdin and write it to a file, and rotate
that once every 100MB or 1GB or whatever you want.
(If it keeps raining I'll do it after dinner :-)
Then just pipe your output to that program. Or let
the rotation program take the command as a parameter.
--
Kasper Dupont -- der bruger for meget tid paa usenet.
I'd rather be a hammer than a nail.
Kasper Dupont
2004-07-09 15:21:38 UTC
Permalink
Post by Kasper Dupont
It shouldn't take much work to write a program, that
will read stdin and write it to a file, and rotate
that once every 100MB or 1GB or whatever you want.
(If it keeps raining I'll do it after dinner :-)
Then just pipe your output to that program. Or let
the rotation program take the command as a parameter.
Actually I wrote that yesterday, but the newsserver
was down, so it got a bit delayed. Anyway, I did write
a small program that can do more or less what you
requested. I was written quite quickly, so probably
there will be a lot of bugs to resolve. And if the
loging program fails to write to the log, your program
will probably die with SIGPIPE.

You could call the program more or less like this:
nohup rotate 100000000 command
--
Kasper Dupont -- der bruger for meget tid paa usenet.
I'd rather be a hammer than a nail.
Loading...