I want to continuously monitor some log files. What I have below works if I switch the tail -F
for cat $log_file
. When I use -tail -F
the first log file works but because its process doesn't finish it blocks the top while
loop.
How can I background each process so that the outer while read log_file
starts a process for each log file? (also tried adding &
in various places to background the inner while loop)
ls /var/log/myApp-*.log | while read log_file ; do
tail -F $log_file while read log ; do
echo send $log to external tracker for $log_file if X
done
done
log_file
? – RomanPerekhrest Dec 05 '17 at 12:27{ "name": "PeriodicWork", "hostname": "myHost", "pid": 12189.20, "level": 20, "msg": "Executing [CheckFailedTask NodeId=8]", "time": "2017-12-04T00:20:30.953Z", "v": 0 }
I need to check if the level is 50 or over and if so sendmsg
,pid
, andname
to another server. – Philip Kirkbride Dec 05 '17 at 12:29$log_file
is each result fromls /var/log/myApp-*.log
. – Philip Kirkbride Dec 05 '17 at 13:58echo
code would be in the real version? – Philip Kirkbride Dec 05 '17 at 14:01