Skip to content

Instantly share code, notes, and snippets.

@swiftgeek
Created October 6, 2012 09:35
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 swiftgeek/3844495 to your computer and use it in GitHub Desktop.
Save swiftgeek/3844495 to your computer and use it in GitHub Desktop.
timer=0
timeout=300
index=0
for arg in $@ ; do
let "index++"
if [ $index -lt $# ]; then
for (( ii=25 ; i<1; i-- )) ; do
[[ -n "$(pgrep $arg)" ]] && echo "Found $arg" && continue 3
[[ $ii -eq 1 ]] && echo "Failed on waiting for $arg" && exit
[[ $timer -ge $timeout ]] && echo "Timeout after $timer" && exit
sleep 5
let "timer+=5"
done
fi
sleep 5
echo "Executing $arg"
exec $arg
done
echo "This shouldn't happen"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment