English 中文(简体)
工作间隔时间比起高
原标题:Logs rotating faster than cron batch job run interval
  • 时间:2011-11-23 15:29:21
  •  标签:
  • bash
  • logging

我们有按规模轮流使用的申请记录,即: 每当该记录达到1mb时,该记录仪的档案从博客改为bc.log.201110329656等。 发生这种情况时,博客从零开始。 日志轮换的频率约为30分钟。

在博客的背景下,我们有争斗的团队工作,以检查每30名未成年人的无身份者例外。

问题有时比下批工作可以更快地轮换,造成无标识者例外,因为批量工作没有机会经营。

是否有办法解决这一问题? 无,我不能改变申请伐木、面积、姓名或轮换的行为。 我不能改变十字军的频率,这种频率固定在30分钟。 然而,我可以自由改变作为双篮子的其他工作。

如何解决这一问题?

最佳回答

你非常详细地描述了问题:

  • You have a log that automatically rolls when the log gets to a certain size.
  • You have another job that runs against the log file, and the log file only.
  • You can t adjust the log roll, and you can t adjust when the check of the log happens.

因此,如果日志变更,你正在查找错误档案。 您是否能够检查你以前用手脚检查过的所有记录档案? 或者,是否只允许检查目前的记录档案?

这样做的一个途径是跟踪你上次检查记录档案时的情况,然后检查所有比你上次检查时更新的记录。 您可为此使用一个名为last.check的文件。 这份档案没有内容(内容无关紧要),但你利用该档案中的时间段,在你最后的航海中显示。 届时,你可以使用<代码>touch,以便在你成功核对记录后改变时间序列:

last_check="$log_dir/last.check"
if [ ! -e "$last_check" ]
then
    echo "Error: $last_check doesn t exist"
    exit 2
fi
find $log_dir -newer "$last_check" | while read file
do
    [Whatever you do to check for nullpointerexception]
done
touch "$last_check"

您可创建原始<代码> 最终_check。 使用<代码>touch的文档 指挥:

$ touch -m 201111301200.00 $log_dir/last.check  #Touch date is in YYYYMMDDHHMM.SS format

Using a touch file provides a bit more flexibility in case things change. For example, what if you decide in the future to run the crontab every hour instead of every 30 minutes.

问题回答

您的朋友是:

$ find /var/log/myapp -cmin -30 -type f -name  abc.log* 

这使你在<编码>/瓦尔/log/myapp下拥有所有记录档案的清单。 在过去30分钟里,有人提到。 请您在all上打字。 这些档案。





相关问题
Best logging approach for composite app?

I am creating a Composite WPF (Prism) app with several different projects (Shell, modules, and so on). I am getting ready to implement logging, using Log4Net. It seems there are two ways to set up the ...

How to make logging.debug work on Appengine?

I m having a tough time getting the logging on Appengine working. the statement import logging is flagged as an unrecognized import in my PyDev Appengine project. I suspected that this was just an ...

How to validate Java logging properties files?

I have a basic facility for allowing users to remotely apply changes to the logging files in my application. Some logs are configured using java.util.logging properties files, and some are configured ...

Logging SAS scripts

I ve been developing a lot of Java, PHP and Python. All of which offer great logging packages (Log4J, Log or logging respectively). This is a great help when debugging applications. Especially if the ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

热门标签