Introduction:
For a specific use case , it was asked to create jobs running same script on 30 agents ,each one defined on its dedicated server.
Also depending on the server list ,we had to start jobs with specific users.
So is there a way avoid to create 30 individual jobs?
Maybe we can find an optimal solution and guess it is by using Control-M hostgroup feature!
Name your host groups and add the Control-M agents inside
- Go on CCM and create your first hostgroup:
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB1.png)
- Add the server to each hostgroup:
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB2ADDSERVERTOHSTGRP-1.png)
- Repeat the task for each of the hostgroups ( example HOSTGROUP1 I have added SERVER4,SERVER7 and removed SERVER1 ),HOSTGROUP2,HOSTGROUP3 and so on.
Define your jobs using dedicated host groups
- So for our example we have 4 jobs, each one referring to a specific Hostgroup in that way:
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOBtab.png)
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB-1024x446.png)
Add the corresponding hostgroups and user to the corresponding jobs
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB4jobs_orderedHISTNAME-1024x392.png)
Important note:
Don’t forget to tick the box “Run job on all Hosts in the group“
This will have for effect to execute the command on all of the hostname in the hostgroup instead of sending command to the first server available
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB4jobs_orderedALLJOBSORDER-1024x210.png)
Order your job
- Right click on the job and select order:
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB5order2.png)
- We will order it on hold status for this test:
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB5order1-1024x565.png)
- When your job is ordered you will see that a job is ordered for each of the agent defined in the hostgroup ( here we have two jobs: one for SERVER4 and one for SERVER7 with same name but different order ID )
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB3jobs_ordered-2-1024x507.png)
- When we check the job properties we can see that “Host group” field HOSTGROUP1 is replaced directly by the hostname SERVER4
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB4jobs_SERVER4-1-1024x436.png)
- For the second job it will be SERVER7 as expected:
![](https://www.dbi-services.com/blog/wp-content/uploads/sites/2/2023/02/HGJOB4jobs_orderedHISTNAME8-1-1024x439.png)
You can repeat this action for each of the hostgroup created and update the job definition with the specific user.
In example HOSTGROUP2 will run the job created for SERVER3/5/6 with user USR2
You will have as a result as many jobs as you have defined agent in the hostgroup 🙂
Conclusion
We can see that you can create a simple job to run it on multiple hosts ,that will ease your life if you need to manage this specific use case . 🙂
Don’t forget to visit dbi bloggers to have more and more valuable tips and trick on your favorite software 🙂