Added an already running check gerrit/nexenta origin/nexenta
authorAlan J. Pippin <ajp@pippins.net>
Sat, 9 Oct 2010 14:31:02 +0000 (08:31 -0600)
committerAlan J. Pippin <ajp@pippins.net>
Sat, 9 Oct 2010 14:31:02 +0000 (08:31 -0600)
zfs-replicate-all

index 8dc4a05baa8f2402419a0f876c21b0004e2fb136..6f105d673064f450780fd13305edc79b8ca5fb35 100755 (executable)
@@ -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