I am facing an issue to use shell script restart server and confirm it restart success immediately after observing multiple strings in sequence, the case is i have to monitor a running log, as example it will generate 4 below information message in sequence, the sequence of these message cannot exchange, otherwise cannot recognize restart success:
We can ignore timestamp, i put it here just for declare how it is in sequence
other log Timestamp 00:05 --> Registering application status UP other log Timestamp 00:10 --> registration status: 204 other log Timestamp 00:50 --> Updating port to 8080 other log Timestamp 01:00 --> Started application in * seconds
So after observing 4 messages one by one when tail the running log, i can terminate the tail and run other operations.
I try some way, like keep
tail the last line on log file, then
tail -f -n 1 monitor_app.log | awk '/Registering application status UP/' tail -f -n 1 monitor_app.log | awk '/registration status: 204/'
either will work individually, but when i try to combine them and even tail the whole log till current time, it failed to keep capture in sequence for 4 messages, e.g
tail -f monitor_app.log | awk '/Registering application status UP/ && /registration status: 204/'
So, how to keep capture strings that come in sequence with
tail the log ? And how to terminate
tail after capture these strings ? Thanks
PS. I am not sure if i have to open
tail 4 times to capture 4 strings and terminate
tail 4 times. The ideal way maybe only using one
tail and keep capturing 4 strings until find all of them, then close the one