2 Replies Latest reply on Dec 19, 2011 9:39 AM by Adam Bowen

    Run a script on a specific number of servers

      I have a customer that must run a weekly script against about 2600 servers in a very specific window on certain days. The issue is that the job to run the script can only complete on about 800 or so servers in the window: there is enough total available time each week to run the script on all the servers but there is not a time available each night to run it on more than a third of the servers. What's more, there is no discernable property or attribute on the servers where I can reliably or consistently divide the servers into smaller groups of about 800 and then run the script job against those smaller groups.


      What I need to do is write a script that will take the group of about 2600 servers and divide it to create four groups of 800 or so servers to run my script against each night. Again, the problem is that there is no defining characteristic or property of the servers that I can use to divide or categorize them into those smaller groups. My thinking is that I need some sort of "count" function" that will count off the first 800 servers in my list and put them in one group, count off the next 800 servers in my list and put them in another group, count off the next 800 servers in my list after that and put them in another group, etc.: with each group of about 800 servers being run one night of the week.


      I confess that this is probably a "Scripting 101" question but I just have not been able to figure it out. Any help or suggestions or even recommendations on alternate ways to accomplish my task?

        • 1. Re: Run a script on a specific number of servers

          Something like:



          while n < 800:


          Echo hello





          Sent from my BlackBerry.

          1 of 1 people found this helpful
          • 2. Run a script on a specific number of servers
            Bill Robinson

            this is from a script i wrote.  in my script i input a batch size (# of servers to target in a batch, so ~800 for you), i also pass the targets in a file (%f option in a type 2 nsh job).  i call a function (createServerGroup) that creates a static server group on the fly, and the later i assign servers 1-799 to that group.  then i create another group, assign servers 800-899, and so on to the end.  you now have a bunch of groups that you can target from some jobs.  ideally you'd kick that job off from this control script.



            local lineStart=1

            local lineEnd=0



            # Read the targets from %f to the job

            totalTargets=`wc -l "${targetGroup}" | awk '{print $1}'`

            while [ ${lineStart} -le ${totalTargets} ]



              # create a server group

              createServerGroup "${parentGroup}" "${templateName}_${groupNumber}"


              targetList=`sed -n ${lineStart},${lineEnd}p ${targetGroup}`

              for server in ${targetList}


               print_debug2 "Adding ${server} to group ${serverGroupId}..."

               BLCLICMD=(StaticServerGroup addServerToServerGroupByName ${serverGroupId} ${server})