Operating System - HP-UX
1832964 Members
2585 Online
110048 Solutions
New Discussion

how to rotate package log file

 
Mauro Gatti
Valued Contributor

how to rotate package log file

Hi all,
I'd like to rotate package log files using logrotate but I don't know how to "reset" the file handler that serviceguard uses. In fact, although logrotate creates new log file and renames old one, serviceguard continues to log into old log file.
Is there any way to do this?

Thank You

Best Regards

Mauro
Ubi maior, minor cessat!
5 REPLIES 5
Murat SULUHAN
Honored Contributor

Re: how to rotate package log file

Hi Mauro

Maybe following script may help you. It's not related with logrotate tool but useful

Best Regards
Murat
Murat Suluhan
Murat SULUHAN
Honored Contributor

Re: how to rotate package log file

Stephen Doud
Honored Contributor

Re: how to rotate package log file

I suspect that once Serviceguard starts a package, it remembers the file descriptor (inode number) for a log file... so even if you change the filename of the package log file in order to rotate it, the inode of the package log file that was used when the package was started is still in memory and will continue to received log messages until the package is halted. Only after halting the package will the in-memory link to the original package log file be severed and a package start will start a new log file or send new messages to the file named .
Mauro Gatti
Valued Contributor

Re: how to rotate package log file

I think so Stephen...
Ubi maior, minor cessat!
Matti_Kurkela
Honored Contributor

Re: how to rotate package log file

In the past, I've successfully rotated ServiceGuard log files with this approach:

cd /etc/cmcluster
gzip < somepackage.cntl.log >somepackage.cntl.log.old && > somepackage.cntl.log

This will gzip the old contents of the active log file into a different file, then immediately truncate the active log file without changing the inode number. The truncation must happen ONLY if the gzipping was completed without errors.

This approach is not perfect: there is a "window of vulnerability" if a message comes in exactly in between the gzip completion and file truncation. In that case, that message might be lost.

MK
MK