Index: trunk/ippTasks/replicate.pro
===================================================================
--- trunk/ippTasks/replicate.pro	(revision 23549)
+++ trunk/ippTasks/replicate.pro	(revision 23561)
@@ -74,6 +74,6 @@
 
   # modify these after the tasks are tested
-  periods      -poll 10
-  periods      -exec 10
+  periods      -poll 0.5
+  periods      -exec 5
   periods      -timeout 1500
   npending     1
@@ -84,17 +84,35 @@
 
   task.exec
+      book npages replicatePending -var N
+      if ($N > 2000)
+        process_cleanup replicatePending
+        break
+      end      
+
       # command does not need to be dynamic, but having it so allows us to adjust the periods
       # so that we dont have to wait 10 minutes for things to start up
       # XXX smaller limited?  7500 will be a huge book of things to do...
-      command neb-admin --host $NEB_HOST --db $NEB_DB --user $NEB_USER --pass $NEB_PASS --pendingreplicate --limit 7500 --so_id_start $SO_ID_START --so_id_range $SO_ID_RANGE
-      periods      -exec 1800
-
-  end
-
-  # success
-  task.exit $EXIT_SUCCESS
+      command neb-admin --host $NEB_HOST --db $NEB_DB --user $NEB_USER --pass $NEB_PASS --pendingreplicate --limit 500 --so_id_start $SO_ID_START --so_id_range $SO_ID_RANGE
+      # periods      -exec 1800
+  end
+
+  # success : 0 -- we did not hit the limit, advance so_id counter
+  task.exit 0
     # advance the so_id counter
-    $SO_ID_START += $SO_ID_RANGE
-
+    $SO_ID_START = $SO_ID_START + $SO_ID_RANGE
+
+    # convert 'stdout' to book format
+    ipptool2book stdout replicatePending -key key -uniq -setword pantaskState INIT
+
+    if ($VERBOSE > 2)
+      book listbook replicatePending
+    end
+
+    # delete existing entries in the appropriate pantaskStates
+    process_cleanup replicatePending
+  end
+
+  # success : 1 -- we DID hit the limit, do NOT advance so_id counter 
+  task.exit 1
     # convert 'stdout' to book format
     ipptool2book stdout replicatePending -key key -uniq -setword pantaskState INIT
@@ -131,6 +149,6 @@
 # create the desired replicas
 task	       replicate.run
-  periods      -poll $RUNPOLL
-  periods      -exec 30
+  periods      -poll 0.5
+  periods      -exec 5
   periods      -timeout 30
 
@@ -139,5 +157,5 @@
     if ($NETWORK == 0) break
     if ($N == 0)
-        periods -exec 30
+        periods -exec 5
         break
     end
