Skip to content

Instantly share code, notes, and snippets.

@hardboiled
Created November 7, 2017 20:01
Show Gist options
  • Save hardboiled/bcc532af2acf6714b94e82e55bc8a1f5 to your computer and use it in GitHub Desktop.
Save hardboiled/bcc532af2acf6714b94e82e55bc8a1f5 to your computer and use it in GitHub Desktop.
#/bin/bash
# usage: $PID=<process_id_to_wait_on> $SCRIPT=<script_to_run_after_process_exits> sh ./run-script-on-process-complete.sh
STR="$(ps -opid | grep $PID | grep -v grep)"
echo $STR
while [ "$STR" = "$PID" ]; do
sleep 1;
STR=`ps -opid | grep $PID | grep -v grep`
done
sh $SCRIPT 2 > errors.log > output.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment