Skip to content

Instantly share code, notes, and snippets.

@agriffis
Last active December 16, 2015 14:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agriffis/5452495 to your computer and use it in GitHub Desktop.
Save agriffis/5452495 to your computer and use it in GitHub Desktop.
wait_for_it.bash 30m deploy
#!/bin/bash
sleep_for=$1
shift
(
"$@"
status=$?
if [[ $status == 0 ]]; then
zenity --info --text="Finished" &
else
zenity --error --text="Failed (status=$status)" &
fi
exit $status
) &
wait_for_pid=$!
(
sleep $sleep_for
if kill -0 $wait_for_pid &>/dev/null; then
zenity --error --text="Still running after $sleep_for" &
fi
) &
sleeper_pid=$!
trap "kill $wait_for_pid $sleeper_pid &>/dev/null; exit" 0 1 2 3 15
wait $wait_for_pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment