#!/bin/sh #run given command #Install this script in /usr/bin on an MBARI LRAUV self=`basename $0` : ${dir:=/mnt/mmc/started} [ "$1" -a "$1" != '--help' ] || { echo "\ Background command detached from any controlling tty -- 6/2/20 brent@mbari.org Usage: $self command {args} Outputs the name of the file receiving merged STDOUT and STDERR output Environment Variables: name=name of command [first argument] dir=directory containing output files [$dir] out=full path to output file {overrides $dir/\$name} Generally: $self {anyCommand} Example: name=onESPclient $self sh -c \"echo slot spare:3 | onESP espclient myName\" Note that the last example may be shortened to: onESPclient myName -- slot spare:3" >&2 exit 2 } [ "$out" ] || { mkdir -p $dir || exit out=$dir/`date +%F%Z%H%M%S`_${name-$1} } echo $out nohup "$@" >$out 2>&1 &