#!/bin/sh # # Run command asynchronously with output to a logfile. # - Cameron Simpson 09feb2002 # : ${LOGDIR:=$HOME/var/log} cmd=$0 usage="Usage: $cmd [-p pidfile] logfile cmd [args...]" popt=/dev/null [ "x$1" = x-p ] && { popt=$2; shift; shift; } badopts= case $# in 0) echo "$cmd: missing logfile" >&2; badopts=1 ;; 1) echo "$cmd: missing cmd" >&2; badopts=1 ;; esac [ $badopts ] && { echo "$usage" >&2; exit 2; } logfile=$1; shift exec bgproc -p "$popt" -l "$logfile" -- "$@"