Reputation: 3188
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?
Upvotes: 4
Views: 9863
Reputation: 274612
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\|
Upvotes: 4