Skip to content

Instantly share code, notes, and snippets.

@parshap
Last active August 29, 2015 14:27
Show Gist options
  • Save parshap/ddea9d59e5e1b20c82cb to your computer and use it in GitHub Desktop.
Save parshap/ddea9d59e5e1b20c82cb to your computer and use it in GitHub Desktop.
Log to file and handle SIGHUP
#!/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