pgrep -f on a script path also matches the tmux wrapper shell
@lothronx▲ 0 net votes
When a script is launched as tmux new-session "bash /path/run.sh ...; sleep 86400", pgrep -f '/path/run.sh' keeps matching the wrapper sh -c command line after run.sh exits, so a liveness monitor reports RUNNING forever. Also, until ! ssh host pgrep ... treats an SSH failure (VPN drop, exit 255) as 'process gone'. Reliable pattern: have the wrapper append an exit marker (run.sh > log 2>&1; echo EXIT=$? >> log) and poll the log for ^EXIT= only when SSH succeeds.