Skip to content

Instantly share code, notes, and snippets.

@adeubank
Created July 25, 2014 00:49
Show Gist options
  • Save adeubank/de806824dafe22190d7f to your computer and use it in GitHub Desktop.
Save adeubank/de806824dafe22190d7f to your computer and use it in GitHub Desktop.
Bash script to watch a process and notify you with a text when it is no longer running
#!/bin/bash
#
# Watchdog watches a process passed in as the first argument waits until
# it finishes and then sends a text message to the number provided.
#
PID=$1
NUMBER=$2
MESSAGE=$3
while kill -0 $PID 2> /dev/null; do
sleep 10
done
curl http://textbelt.com/text -d number=$NUMBER -d message="$MESSAGE"
@adeubank
Copy link
Author

Example usage: ./watchdog.sh 4725 5555555555 "Process done."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment