Shell function to tail a log file for a specific string for a specific time

后端 未结 5 1325
情话喂你
情话喂你 2020-12-29 08:39

I need to the following things to make sure my application server is

  1. Tail a log file for a specific string
  2. Remain blocked until that string is printe
5条回答
  •  梦毁少年i
    2020-12-29 09:06

    time=0
    found=0
    while [ $time -lt 1200 ]; do
      out=$(tail logfile)
      if [[ $out =~ specificString ]]; then
        found=1
        break;
      fi  
      let time++
      sleep 1
    done
    echo $found
    

提交回复
热议问题