nginxのgraceful shutdownを待ってから処理を行いたいことがあったので、その時に作ったシェルスクリプト。
nginxの終了判定はpgrep nginxを使用。
$ nginx -s quit
$ while pgrep nginx > /dev/null; do sleep 0.1; done;$ # なんか処理何かしら問題があると怖いので、実際にはタイムアウトをくっつけて使用。
$ nginx -s quit
$ timeout 5 bash -c -- 'while pgrep nginx > /dev/null; do sleep 0.1; done;'$ # なんか処理while ! pgrep nginx > /dev/null; do sleep 0.1; done;のようにすれば起動待ちにも使える。