Basically you connect the output of nohup to a pipe that is redirecting to a file - then the file can me moved around very easily.
mknod /tmp/mypipe p cat < /tmp/mypipe >/tmp/myreallog nohup myapplication >/tmp/mypipe To rotate the log: mv /tmp/myreallog /tmp/rotatedlog kill [pid of the cat process] cat < /tmp/mypipe >/tmp/myreallog
2 comments:
This was great. I was able to incorporate the concept to rotate nohup logs growing quickly from FD exhaustion.
Just before you do your nohup call, just add :
cat < /tmp/mypipe > /dev/null &
With this addition, the nohup will survive if the other "cat" process is killed, if the nohup task writes to it before the "cat" process is recreated.
Post a Comment