Re: (Fwd) Re: Informix Message Log
Posted in 1996
} } Jack Parker wrote (in reply to a bunch of others): } > } > There is still the risk that the file will be being written to during your } > mv. Which is why I prefer: } > } > tdy=`date +"%Y%j"` } > cp $logfile $logfile.$tdy } > cat /dev/null > $logfile } > } > The file is never 'gone' that way. Sure an 'mv' to the same file system } > is going to take a millsecond - so it's probably never going to be an issue. } > Sure a 'cp' is slower. } } Your way is actually worse as there is a window of opportunity where you are } truncating the file while someone else is writting to it. When you use mv, you } are only renaming the directory entry. Any open file descriptors in the kernel } stay open and all pending messages will get correctly written and flushed. The } next open() will cause the file to be created. Under Unix this should be } guaranteed atomic. That is why creat() is used as a lock method. cp and > are } not, and there is the potential for loss. } } Cosmo } -- } simond@informix.com } There's go Jack spreading misinformation around again. :-0 cheers j. _____________________________________________________________________________ Jack Parker - Hewlett Packard, DMD/IS Boise, Idaho, USA jparker@boi.hp.com Currently on loan to PLD/PE _____________________________________________________________________________ If anything can go wrong, fix it. To hell with Murphy. _____________________________________________________________________________ Any opinions expressed herein are my own and not those of my employers. _____________________________________________________________________________