Skip to content

Instantly share code, notes, and snippets.

@matthewfl
Created March 4, 2026 17:01
Show Gist options
  • Select an option

  • Save matthewfl/6a6ad960fd3e7cf1fbc659c15b39034b to your computer and use it in GitHub Desktop.

Select an option

Save matthewfl/6a6ad960fd3e7cf1fbc659c15b39034b to your computer and use it in GitHub Desktop.
Wait for a command to finish
#!/bin/bash
WAITNAME=$0
SNAME=$1
if [ -z "$SNAME" ]; then
echo "use wait-for 'proc-search-string'"
exit 1
fi
while [ 1 ] ; do
ps aux | grep -v $WAITNAME | grep -v grep | grep $SNAME > /dev/null
if [ $? -ne 0 ]; then
echo "Process \"$SNAME\" not found, exiting at `date`"
exit 0
fi
printf "found \"$SNAME\" at `date`\r"
sleep 5s
done
echo $SNAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment