我遇到的问题是,一旦logrotate将当前日志文件移动到新文件中,新创建的日志文件就不再填充日志了.似乎删除原始日志文件后,其文件处理程序将丢失,重定向将不再起作用.
我还发现this post与我有同样的问题,并声称可以通过使用>>来修复它.而不是>重定向输出.我测试了他的解决方案,但它对我不起作用.有谁知道如何保持重定向工作?
解决方法 您应该在logrotate配置中使用copytruncate指令来获取此日志文件.总结copytruncate 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
以上是内存溢出为你收集整理的linux – 如何在logrotate移动后继续将stdout重定向到文件?全部内容,希望文章能够帮你解决linux – 如何在logrotate移动后继续将stdout重定向到文件?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)