#!/bin/bash export PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin match=$1 dir=$2 if [ -z "$3" ]; then echo "too few options: $1 $2" echo "usage: $0 pattern start_dir command [options]" exit fi if [ ! -d $dir ]; then echo "no dir $dir" exit fi cd $dir shift;shift #pwd #echo :$match: #ps wwax | grep -v grep | grep "$match" mkdir /tmp/cron-restart-job 2> /dev/null chmod 1777 /tmp/cron-restart-job if [ -z "`ps axwww | grep -v "grep $match" | grep -v "$0" | grep "$match"`" ]; then # echo $* ( eval $* < /dev/null >& /dev/null & ) >& /dev/null < /dev/null & echo `date`:$* >> /tmp/cron-restart-job/$match.log fi