linux – 旋转一个始终打开并正在写入的文件
发布时间:2020-05-24 22:31:55 所属栏目:Linux 来源:互联网
导读:我有一个 linux应用程序,它不断将日志信息写入日志文件,例如. /var/log/application.log.由于应用程序不会自动旋转文件,因此该日志文件在几周内可达到千兆字节大小,因此我希望能够正确旋转此文件 我主要担心的是,要始终旋转应用程序打开的文件,我可能需要:
|
我有一个 linux应用程序,它不断将日志信息写入日志文件,例如. /var/log/application.log.由于应用程序不会自动旋转文件,因此该日志文件在几周内可达到千兆字节大小,因此我希望能够正确旋转此文件 我主要担心的是,要始终旋转应用程序打开的文件,我可能需要: >将文件移动到其旋转形式/var/log/application.log – > /var/log/application.log.2013-01-28 所以,我是对的吗?如果是这样,我该怎么做? (主要是改变文件描述符部分) 如果我不是,那么正确的方法和方法是什么? 解决方法编写logrotate配置以使用copytruncatecopytruncate
Truncate the original log file in place after creating a copy,instead of moving the
old log file and optionally creating a new one. It can be used when some program
cannot be told to close its logfile and thus might continue writing (appending) to
the previous log file forever. Note that there is a very small time slice between
copying the file and truncating it,so some logging data might be lost. When this
option is used,the create option will have no effect,as the old log file stays
in place. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
