Configuring scheduled tasks to run on any server

We have a number of scheduled tasks that I'd like to run on any of our Active Roles servers, but I'm not keen on them running on all the servers each time.

I know you can configure them to run on All Servers, but I'm wondering if there is a way to configure them to run on any server, i.e. only one server in the farm starts the job at the defined schedule.

I have been looking at the attributes on the task to see if I can detect if the job is running and on which server, but I cannot find anything that will help me there.

Parents
  • Quick answer, no. There isn't an option for "Any Server" for "Excute on", or for the use of "All Servers".

    Some out of the box Scheduled tasks will run on "All Servers", like the "Change Tracking Cleanup" builtin Scheduled Tasks 

    All other scheduled tasks as defined to run on a named ARS instance (OOtB, or custom schedules) like "Update Services To ExecuteOn" which is the schedules task used to update the server on which certain tasks take place as part of the upgrade step 

    This last Schedule task how might give you a clue (See Description: "Updates the services to execute on for Dynamic Groups, Scheduled Tasks, Temporal Groups and Group Families."), so you could have a custom schedule task, that run a script to change which server something executes on.

    Would I recommend changing everything, like in an upgrade, no. But if you have particular requirements that means you need to change which server something runs on, for the next execution of the schedule, then you could do something similar ONLY for the schedules you create.

    However, the more apt question is why do you have this need? What's the problem you're trying to mitigate?

    In terms of detecting if the job is running, have a look a Get-QADObject (object class edsScheduledTask, and probably edsaTaskState (or if available edsvaTaskStateString), like the below (created from something retrieved from Checking your ARS Scheduled tasks ran OK | clan8blog)

    $SelectedProperties = @(
        'name'
        'edsaDisableSchedule'
        'edsaLastRunTime'
        'edsvaNextRunTime'
        'edsaLastActionMessage'
        'edsaTaskState'
        'edsvaIsReadyToTerminate'
        'edsvaServerNameToExecute'
        'edsvaTaskStateString'
        'DN'
        'ParentContainerDN'
        'edsaXMLSchedule'
    )
    
    $SearchRoot     = "CN=Builtin,CN=Scheduled Tasks,CN=Server Configuration,CN=Configuration"
    $ScheduledTasks = Get-QADObject -SearchRoot $tasksOU -IncludedProperties $SelectedProperties -Type edsScheduledTask -proxy | select $SelectedProperties
    $ScheduledTasks | Out-GridView

Reply
  • Quick answer, no. There isn't an option for "Any Server" for "Excute on", or for the use of "All Servers".

    Some out of the box Scheduled tasks will run on "All Servers", like the "Change Tracking Cleanup" builtin Scheduled Tasks 

    All other scheduled tasks as defined to run on a named ARS instance (OOtB, or custom schedules) like "Update Services To ExecuteOn" which is the schedules task used to update the server on which certain tasks take place as part of the upgrade step 

    This last Schedule task how might give you a clue (See Description: "Updates the services to execute on for Dynamic Groups, Scheduled Tasks, Temporal Groups and Group Families."), so you could have a custom schedule task, that run a script to change which server something executes on.

    Would I recommend changing everything, like in an upgrade, no. But if you have particular requirements that means you need to change which server something runs on, for the next execution of the schedule, then you could do something similar ONLY for the schedules you create.

    However, the more apt question is why do you have this need? What's the problem you're trying to mitigate?

    In terms of detecting if the job is running, have a look a Get-QADObject (object class edsScheduledTask, and probably edsaTaskState (or if available edsvaTaskStateString), like the below (created from something retrieved from Checking your ARS Scheduled tasks ran OK | clan8blog)

    $SelectedProperties = @(
        'name'
        'edsaDisableSchedule'
        'edsaLastRunTime'
        'edsvaNextRunTime'
        'edsaLastActionMessage'
        'edsaTaskState'
        'edsvaIsReadyToTerminate'
        'edsvaServerNameToExecute'
        'edsvaTaskStateString'
        'DN'
        'ParentContainerDN'
        'edsaXMLSchedule'
    )
    
    $SearchRoot     = "CN=Builtin,CN=Scheduled Tasks,CN=Server Configuration,CN=Configuration"
    $ScheduledTasks = Get-QADObject -SearchRoot $tasksOU -IncludedProperties $SelectedProperties -Type edsScheduledTask -proxy | select $SelectedProperties
    $ScheduledTasks | Out-GridView

Children
No Data