24.0 Job templates > Job template how-to's > Applying templates based on job attributes

Conventions

24.3 Applying templates based on job attributes

To apply a job template based on job attributes

  1. In the Moab configuration file, create a job template with a set of criteria that a job must meet in order for Moab to apply the template. In the following example, Moab will apply a template to all interactive jobs, so the first template sets the interactive flag.
  2. JOBCFG[inter.min] FLAGS=interactive

  3. Create the job template that Moab should apply to the job if it meets the requirements set in the first template. In this example, Moab ignores all configured policies, so the second template sets the ignpolicies flag.
  4. JOBCFG[inter.set] FLAGS=ignpolicies

  5. Use the JOBMATCHCFG parameter and its JMAX or JMIN (specify the template specifying maximum or minimum requirements) and JDEF or JSET (specify the template to be applied) attributes to demonstrate the relationship between the two templates (See Job template matching attributes for more information.). In this case, all interactive jobs ignore policies; in other words, if a submitted job has at least the inter.min template settings, Moab applies the inter.set template settings to the job.
  6. JOBMATCHCFG[interactive] JMIN=inter.min JSET=inter.set

    Moab applies the inter.set template to all jobs with the interactive flag set, causing them to ignore Moab's configured policies.

  7. To control which job template is applied to a job that matches multiple templates, use FLAGS=BREAK. Job templates are processed in the order they are listed in the configuration file and using the BREAK flag causes Moab to stop evaluating JOBMATCHCFG entries that occur after the current match.
    JOBMATCHCFG[small] JMIN=small.min JMAX=small.max JSET.set=small.set FLAGS=BREAK
    JOBMATCHCFG[large] JMIN=large.min JMAX=large.max JSET=large.set

    In this case, the large template would not be applied when a job matches both the small and large templates. The small template matches first, and because of FLAGS=BREAK, Moab stops evaluating further JOBMATCHFG entries for the job.

Related topics