Creating a Maintenance Window in JAMS

Follow

The maintenance window is used to temporarily stop Jobs from running within your environment. This is useful when performing maintenance or upgrades on your system. You can create a maintenance window by adding a Resource Definition to one or more folders containing Jobs. When the maintenance window is enabled, Jobs will continue to enter the schedule and the monitor view, but they will not execute until the maintenance window is disabled.

You have two options for a maintenance window:

  • Manually enable/disable the maintenance window.
  • Automatically enable/disable the maintenance window.

NOTE: Jobs that are currently executing when you enable the maintenance window are allowed to finish executing. Ensure Jobs have enough time to finish prior to patching or taking down servers during the maintenance period.



NOTE: If you are running any Jobs from mail or file watches, those Jobs will continue to run after the maintenance window is enabled.


 


Manually Enabling and Disabling a Maintenance Window

Create a New Resource for the Maintenance Window

  1. Click Resources in the Shortcuts bar.
  2. Click the + button to add a resource. The Add a Resource Definition dialog is displayed.
  3. In the Name field, enter Maintenance_Window.
  4. In the QtyAvailable field, enter 0.
  5. In the Edit the Resource Definition After Adding field, clear the checkbox.
  6. Click Ok.

Add the Maintenance Window Resource Requirement to your Jobs

After the maintenance window resource has been created, add it to one or more folders. The procedure below adds it to a root folder, so it applies to all Jobs under the root folder.

  1. Click Definitions from the Shortcuts bar.
  2. In the Folder Navigator, right-click a root folder and select Properties.
  3. Click the Schedule tab.
  4. Click the + button and select This Job depends on a | Resource.
  5. In the Resource field, select the Maintenance_Window resource.
  6. In the Quantity Required field, enter 1.
    Add_Maintenance_Window.png
  7. Click Finish.
  8. Click Save and Close.

Manually Enable the Maintenance Window

Enabling the maintenance window allows Jobs to continue to enter the schedule, but the Jobs will not execute until the Maintenance Windows is disabled. 

  1. Click Resources from the Shortcut bar.
  2. Double-click Maintenance_Window.
  3. Click the Available tab.
  4. In the Quantity Available field, enter 0.
  5. Click Save and Close.

Manually Disable the Maintenance Window

After the upgrade or maintenance has been completed, you can disable the maintenance window to allow the queued Jobs to begin executing again.

  1. Click Resources from the Shortcut bar.
  2. Double-click Maintenance_Window.
  3. Click the Available tab.
  4. In the Quantity Available field, enter 999999.
  5. Click Save and Close.

Automatically Enabling and Disabling a Maintenance Window

You can automate the process of enabling and disabling the maintenance window by creating two PowerShell Jobs in JAMS in the root folder. When you automate this process, the maintenance window resource is not set at the root level. Set the resource on all lower folders and not at the root. This ensures that the two Jobs are not dependent on the maintenance window resource.

Create a New Resource for the Maintenance Window

  1. Click Resources in the Shortcuts bar.
  2. Click the + button to add a resource. The Add a Resource Definition dialog is displayed.
  3. In the Name field, enter Maintenance_Window.
  4. In the Quantity Available field, enter 999999.
  5. In the Edit the Resource Definition After Adding field, clear the checkbox.
  6. Click Ok.

Add the Maintenance Window Resource to all Non-Root Folders

Repeat these steps on each non-root folder in your Folder Navigator.

  1. Click Definitions from the Shortcut bar.
  2. Right-click on a non-root folder and select Properties.
  3. Click the Schedule tab.
  4. Click the + icon.
  5. Select This Job depends on a | Resource.
  6. In the Resource field, select Maintenance_Window.
  7. In the Quantity Required field, enter 1.
  8. Click Finish.
  9. Click Save and Close.
    Resource.png
  10. Repeat for each non-root folder.

Create a Job to Automatically Enable the Maintenance Window Resource

  1. Click Definitions from the Shortcut bar.
  2. Open the root folder.
  3. Click + and create a PowerShell Job.
  4. In the Source tab, enter the script below to set the maintenance window resource to 0:
    Import-Module JAMS
    $resource = Get-Item JAMS::localhost\Resources\"Maintenance_Window"
    $resource.QuantityAvailable = 0
    $resource.Update()
  5. On the Schedule tab, do the following:
    1. Click the + icon.
    2. Select Run this Job | on a schedule.
    3. Select a date/time before the planned maintenance. This is when the maintenance window will start.
    4. Click Finish.
  6. On the Properties tab, select an Execute As account.
  7. Click Save and Close.
  8. Ensure that all Jobs currently executing after the Maintenance Window Resource has been set to 0 are allowed to finish before the server reboot.

Create a Job to Automatically Disable the Maintenance Window Resource

  1. In the Definitions shortcut, open the root folder.
  2. Click + and create a PowerShell Job.
  3. In the Source tab, enter the script below to set the Maintenance Window Resource back to 999999.
    Import-Module JAMS
    $resource = Get-Item JAMS::localhost\Resources\"Maintenance_Window"
    $resource.QuantityAvailable = 999999
    $resource.Update()    
  4. On the Schedule tab, do the following:
    1. Click the + icon.
    2. Select Run this Job | on a schedule.
    3. Select a date/time after the planned maintenance. This is when the maintenance window will end.
    4. Click Finish.
  5. On the Properties tab, select an Execute As account.
  6. Click Save and Close.
  7. Ensure that no other jobs are defined on the root folder besides the two jobs that change the maintenance window resource.

Disable the Schedule in the Maintenance Window Jobs after the Maintenance Window

After the maintenance window has completed, ensure you disable the schedules that you added to the two Jobs created in the previous steps. Otherwise, the maintenance window will run again at the specified date and time.

  1. Click Definitions from the Shortcut bar.
  2. Right-click the Job that enables the maintenance window in the root folder and select Properties.
  3. Click the Schedule tab.
  4. Double-click the Schedule item for the maintenance window.
  5. Clear the Enabled checkbox.
    DisableSchedule.png
  6. Click Save and Close.
  7. Repeat for the Job that disables the maintenance window in the root folder. 
Have more questions? Submit a request

Comments

  • Avatar
    Ben Kiel

    I had to bounce the JAMS Scheduler services before the change took effect.

  • Avatar
    Gennaro Piccolo

    Hello Ben, you shouldn't have to do that, if you're continuing to have an issue, and you can replicate it, let us know in a ticket, and we'll take a look.

  • Avatar
    Greg Emery

    Is there a way to pause Filewatchers with a Maintenance Window?

  • Avatar
    Gennaro Piccolo

    Hi Greg, if a File Watch job is running, it can't be paused. If you turn off the Maintenance Window, then cancel the file watch job, the file watch job will be resubmitted and then be put on hold. It can be held using that method.

  • Avatar
    Marc Wenrich

    Question:
    Is there a way to only choose subfolders and not all folders under the Root folder when you create a maintenance window?
    I would like to have separate windows for Production jobs and Non-Production jobs that are in separate folders.

  • Avatar
    Gennaro Piccolo

    Hello Marc,

    Elements defined on a folder are inherited by all objects below that folder. If you have root, and then prod and non prod under root, it still is a good idea to have a "main window" on the root folder, and then create additional windows for each prod and non-prod folder, so that each resource can be controlled independently.