Skip to content

Instantly share code, notes, and snippets.

@kevboutin
Created March 29, 2020 22:26
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 kevboutin/017444a993633c757e602f3c8b660bf1 to your computer and use it in GitHub Desktop.
Save kevboutin/017444a993633c757e602f3c8b660bf1 to your computer and use it in GitHub Desktop.
This demonstrates how a bash script can invoke a child process to do some work asynchronously and monitor for finish
#!/bin/bash
mycommand &
child_pid=$!
while kill -0 $child_pid >/dev/null 2>&1; do
echo "Child process is still running"
sleep 1
done
echo "Child process has finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment