I have this bash script and inside the script, I am trying to grep a log for the words "status change" and then after I find the most recent line that contains the words "status change" (aka the most recent status change), I grep that line for the word "Backup".
The problem is that I am currently putting it to sleep for 15 seconds first so the log has time to be updated of the most recent status change but I want a better solution for this.
I want it to actively check for the status and report a failure only after 15 seconds. If possible, I would like to only replace my first 2 lines of code because I plan on making other modifications to the rest. Any help would be greatly appreciated! Here is what I currently have:
sleep 15 ssh server_one@$1 "grep 'status change' /apps/tests/$2 | tail -1 | grep 'Backup'" Output=$? if [[ ${Output} -ne 1 ]] ; then echo "Pass: It is Backup" echo "Pass: It is Backup" >> $REPORT else echo "Fail: It is not Backup" echo "Fail: It is not Backup" >> $REPORT fi
active. The code looks for the wordBackup. Which is it?inotifywaitfrom theinotify-toolspackage; and 2. use theperlFile::Tailmodule. Both methods avoid any need to sleep.