Last active
August 29, 2015 14:27
-
-
Save parshap/ddea9d59e5e1b20c82cb to your computer and use it in GitHub Desktop.
Log to file and handle SIGHUP
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 | |
logfile=$1 | |
pidfile=$2 | |
sighup() { | |
exec 0>>$logfile 2>&1 | |
} | |
echo "$$" > $pidfile | |
trap sighup HUP | |
trap "rm -f $pidfile" QUIT EXIT INT TERM | |
sighup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment