Skip to content

Instantly share code, notes, and snippets.

@Rocketeer007
Created November 25, 2016 09:56
Show Gist options
  • Save Rocketeer007/dcaa55e10d7aa9fcf6e316ffa1715018 to your computer and use it in GitHub Desktop.
Save Rocketeer007/dcaa55e10d7aa9fcf6e316ffa1715018 to your computer and use it in GitHub Desktop.
Wait for a process to start, then notify on start and stop of that process
#!/bin/sh
trap "" HUP
PROCESS_NAME=$1
shift
MESSAGE=$*
waitfor.sh "${PROCESS_NAME}" ${MESSAGE} has started
PROCESS_ID=`ps -fu gold | grep -v grep | grep "${PROCESS_NAME}" | grep -v $0 | sed -r "s/ +/ /g" | cut -f2 -d' ' | head -n1`
monitor.sh ${PROCESS_ID} ${MESSAGE} has finished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment