From e27e0c7b91fd87d322736b79974f5488490dd20f Mon Sep 17 00:00:00 2001 From: "Alan J. Pippin" Date: Sat, 9 Oct 2010 08:31:02 -0600 Subject: [PATCH] Added an already running check --- zfs-replicate-all | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/zfs-replicate-all b/zfs-replicate-all index 8dc4a05..6f105d6 100755 --- a/zfs-replicate-all +++ b/zfs-replicate-all @@ -15,6 +15,17 @@ mylogfile="$logdir/zfs-replicate-all.log" date=`date` starttime=`date +%s` +# Make sure we aren't already running +SCRIPT_NAME=${0##*/} +PROCESS_LIST=`tempfile` +ps -ef | grep -e "$SCRIPT_NAME" | grep -v grep | grep -v $$ | grep -v $PPID >> $PROCESS_LIST +if [[ $? == 0 ]]; then + echo "$date Another $SCRIPT_NAME process is already running" >> $mylogfile + cat $PROCESS_LIST >> $mylogfile + exit 1 +fi +[[ -e "$PROCESS_LIST" ]] && rm -f $PROCESS_LIST + # This function checks to see if our runtime has exceeded our stoptime timeexceeded() { if [[ $maxruntime == 0 ]]; then -- 2.34.1