tags:

views:

43

answers:

2

Hi. I need to guarantee that a specific string is appearing in an active log file, meaning an operation is alive (feeding this count to a Trigger).

Considering I'll do this remotely, I can't go with 'tail -f filename' else it would follow the file indefinitely, thus I'm thinking about grabbing a bunch of last written lines and counting them as,

tail -n8 /var/log/service/service_V138/operations.log| grep \|DONE\| | wc -l

Is there any better way?

+1  A: 

You can improve this a bit, by removing the pipe to wc and using grep -c instead.

tail -n8 /var/log/service/service_V138/operations.log | grep -c \|DONE\|
dogbane
Thanks.My main doubt was if there was any alternative method to follow the file for a few seconds before disconnecting, guaranteeing the file was being actively written, just doesn't have the given string.
stack_zen
A: 

less +F -N somelogfile.log ?pattern simple and easy

carlos g
Following the log, inserting a pause in the script, and feeding the ssh conn with a 'CTRL+C' some seconds later right?
stack_zen