superuserの回答を見る。プロセスが終了するまでのテールファイル
私はこれを修正して複数の文字列を聞き取り、 「あなたのサーバが正常に起動した」など
私も別のコマンドにそれをタックしようとしてすなわちピップ
wait_str() {
local file="$1"; shift
local search_term="Successfully installed"; shift
local search_term2='Exception'
local wait_time="${1:-5m}"; shift # 5 minutes as default timeout
(timeout $wait_time tail -F -n0 "$file" &) | grep -q "$search_term" && echo 'Custom success message' && return 0 || || grep -q "$search_term2" && echo 'Custom success message' && return 0
echo "Timeout of $wait_time reached. Unable to find '$search_term' or '$search_term2' in '$file'"
return 1
}
私が考えている使用方法は次のとおりです。
pip install -r requirements.txt > /var/log/pip/dump.log && wait_str /var/log/pip/dump.log
を明確にするため、Iピップが成功するかどうかにかかわらず、終了時にtail_strを停止して終了するのが好きです。
@PSを発見された場合。 'tail'コマンドは終了しません。私はこのようにsthを行う必要があります 'tail -f /var/log/pip/stderr.log | awk '/ Exception/{system( "echo worked!")}' || awk '/ compiler/{system( "echo worked!")} '' 2つの文字列をテストします。 – Jonathan
これらのコマンドは並行して実行されると思われますが、コマンドはシリアル実行を示します。定義によって、 'pip'は' wait_str'が実行されたときに終了します。なぜなら 'pip'を待って終了状態を調べる' && 'を接続しているからです。' pip'が成功したときだけ 'wait_str'を実行します。 – tripleee