Created
March 4, 2026 17:01
-
-
Save matthewfl/6a6ad960fd3e7cf1fbc659c15b39034b to your computer and use it in GitHub Desktop.
Wait for a command to finish
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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