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?
set -e
does? – Ignacio Vazquez-Abrams May 15 '18 at 01:45EXIT STATUS
section ofman pgrep
? – steeldriver May 15 '18 at 01:48