Artificial intelligent assistant

Why is attempting to capture a PID causing my shell script to mysteriously terminate? I'm using CentOS 7. I"m trying to capture the "master PID" of a process in a script variable. This is my script #!/bin/sh set -e PID="$APP_ROOT/shared/pids/puma.pid" echo "before ..." MASTER_PID=`pgrep -f '^([^ ]*/)?puma '` echo "after ..." xxx However, the word "after ..." is never printed out. There's something about this line MASTER_PID=`pgrep -f '^([^ ]*/)?puma '` which is causing things to behave badly, especially if there is no puma process running. Does anyone know a way to rewrite the above so that I can capture my master PID or at least allow execution to pass to the next line if it doesn't exist?

If you want to keep the `set -e`, then you need to keep pgrep from failing, by:


MASTER_PID=`pgrep -f '^([^ ]*/)?puma ' || true`

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy d615a71c3a1a0d17c003a310b80c3bb5