当前位置: 动力学知识库 > 问答 > 编程问答 >

shell - UNIX file change interval

问题描述:

Is there a way to determine change frequency of a file?

The situation is i have a log file which will be rolling all the time, in that way i can say my application is running .

if it's not writing any then i can say there's some problem.

So instead of using tail and see manually if the logs are rolling , how can i check if the log is rolling programmatically like analysing it for 2 mins and checking if logs are being written?

Is there a way to track the change interval by using stat in some program kinda ???

i mean i can take 2 mins as parameter,at first storing mtime and after 2mins checking with new time and confirming it's changed, but i need to know the frequency kinda like x modifications/time or number.of.lines written/sec kinda

网友答案:

A better idea would be to have inotify, gamin, or FAM notify you when the file has been modified.

网友答案:

On a Unix system, the stat() family of functions will obtain a file's metadata. The st_mtime member of the struct stat structure will give you the time of last modification.

Also on a Unix system, sending a signal 0 to a process will tell you if the process is still alive without affecting the process.

分享给朋友:
您可能感兴趣的文章:
随机阅读: