LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   command to find out elapsed time of logfile since last write (https://www.linuxquestions.org/questions/linux-newbie-8/command-to-find-out-elapsed-time-of-logfile-since-last-write-4175508891/)

mrajdeep 06-23-2014 09:47 AM

command to find out elapsed time of logfile since last write
 
Hi, I need to write a script which will continuously monitor a logfile and if nothing is written in that file for 500 miliseconds it will invoke a kill -3 signal to generate core dump. Any help or suggestion to achieve this is highly appreciated.

schneidz 06-23-2014 09:51 AM

Code:

[schneidz@hyper ~]$ touch mrajdeep.txt
[schneidz@hyper ~]$ stat mrajdeep.txt
  File: `mrajdeep.txt'
  Size: 0                Blocks: 0          IO Block: 4096  regular empty file
Device: fd00h/64768d        Inode: 186873      Links: 1
Access: (0664/-rw-rw-r--)  Uid: (  500/schneidz)  Gid: (  500/schneidz)
Context: unconfined_u:object_r:user_home_t:s0
Access: 2014-06-23 10:51:14.306979323 -0400
Modify: 2014-06-23 10:51:14.306979323 -0400
Change: 2014-06-23 10:51:14.306979323 -0400
 Birth: -


mrajdeep 06-23-2014 10:29 AM

Thanks for your response, but how do I determine if 500 miliseconds have passed since the file was last modified.

schneidz 06-23-2014 10:32 AM

maybe the awk command can help check the difference in time... maybe you could convert the yyyy-mm-dd hh:mm:ss.xxxxxxxxx into some sort of unix time ?


All times are GMT -5. The time now is 11:41 PM.