Created
June 1, 2012 17:55
-
-
Save jjt/2854018 to your computer and use it in GitHub Desktop.
Example: Running multiple background processes in one bash script, killing all on SIGINT (ctrl+c)
This file contains 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 | |
SITE=/home/dev/sites/rmx | |
# Arbitrary shell commands, some run in background | |
echo "RMX using siteroot=$SITE" | |
$SITE/rmx/manage.py runserver & | |
compass watch $SITE/media/compass/ & | |
coffee -o $SITE/media/js -cw $SITE/media/coffee & | |
hamlpy-watcher $SITE/templates/hamlpy $SITE/templates/templates & | |
# The magic line | |
# $$ holds the PID for this script | |
# Negation means kill by process group id instead of PID | |
trap "kill -TERM -$$" SIGINT | |
wait |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!