1 2 3 4 5 6 7 8 9 10 11 12
#!/bin/bash TMP=${TMPDIR-/tmp}/daemon running=$(pgrep -u `whoami` "$1") if [ -z "$running" ]; then mkdir -p "$TMP" echo "daemon: starting $1" nohup $@ > "$TMP/$1.out" 2> "$TMP/$1.err" & else echo "daemon: $1 is already running" fi