Sorry if the title doesn't make it clear.
I have a file to be read every 15 mins and find a particular pattern in it (e.g. timeout). File does not have any fixed update frequency.
Outcome expected:- 1. if pattern is found 3 times in 15 mins, run command1. 2. if pattern is found 5 times in 15 mins, run command2.
File to be read from last read position for each check.
Thanks, GRV
One way to do this is with a
cronjob. It is more complicated than other solutions but it is very reliable (even if your "check script" crashes, it will be called up again bycronafter the period elapses). Thecroncould be:The
env DISPLAY=:0might not be needed in your case, or it might be needed, depending on your script (note: you might need to adapt this to your case, run echo$DISPLAYto find out your variable on the case).Your
"checkscript"could be:It is not included on your question, but if you meant to run the commands as well if the pattern is found 4 times or 7 times, then you could change the relevant parts above to: