0

I have a php script that checks the database every second(ish as not 100% important its on second) and writes the output to json files for a captioning system. This has a success log file

I want to log the quite times too.

I was logging to the last line with "." every time it ran.

2012-06-18 10:45:51 UTC | .........................

This can lead to very long line which might break future log checking system.

So I have change this for a line that runs every 5 minutes

// 2012-06-18 10:45:51 UTC | wait.
if ((int) date('i') % 5 == 0) 
{
log ( $date . ' | wait. ' );
}

but this logs every second/iteration of every 5th minute. I could add seconds but it does not always run every 01 second.

Is there a way of logging once in n time?

4

1 回答 1

1

您可以让您的脚本在上次运行时写入辅助临时文件。然后在下一次执行时,它可以加载该值,计算与当前时间和存储值的差异,如果它大于 N,则将您的条目记录到日志文件中。

于 2012-06-18T11:10:34.270 回答