.. _scheduling:

Sync scheduling
-----------------

.. _25.4|EKB-27467:


Overview 
..................

Sync scheduling involves scheduling actions to take place at a specified time, or to repeat. 

Currently, the action is to *execute*.

Single or multiple actions can be executed on one or more resources:

* Data sync
* Script 
* Provisioning workflows
* A schedule can be created during the Bulk Load process.

  Bulk loaded files that are not set to Execute Immediately can be scheduled by 
  Execution Date, -Time and -Timezone. A scheduled bulk load is shown on the
  Schedule as a **Single Execution** schedule type and with the Resource Type as 
  **data/BulkLoad**.

Care should be taken when transactions are scheduled. For example, data syncs should be scheduled outside of 
peak times. The size and scope of the transactions that run determine the length of the time that they need 
to run. This therefore impacts on the start time. The number of clusters on the system and their size 
need to be considered as part of a data sync approach.

.. image:: /src/images/tools-schedules.png


.. rubric:: Related topics

* 
   .. raw:: latex

      Schedule dashboard export report in the Core Feature Guide

   .. raw:: html

      <a href="schedule-dashboard-export-report.html">Schedule dashboard export report</a>





Best practice for scheduling syncs
....................................

* Avoid too many overlapping syncs at a given time. The system already blocks multiple syncs against a given 
  device.
* The best practice is to not have more than five syncs running at a given time.
* To avoid load and issues with concurrency, schedule syncs carefully and at
  intervals when they are really required. For example, do not run nightly syncs unless it is necessary.
  Since syncs generally cover the case where information is changed on the UC apps outside Automate,
  the level of third party integration or direct configuration tasks should play a role in the decision
  to schedule. For details, refer to the topics on Cisco UCM, CUC and LDAP below.
* Since it is possible to limit the number of records processed with a given sync, 
  more predictability can be obtained with scheduling.



.. _enable-a-scheduled-data-sync:

Enable a scheduled data sync
................................

.. tip:: 

   :ref:`use-action-search-to-navigate-automate`


This procedure enables the scheduled data sync so that it executes regularly.  

.. note:: 
   
   Setting up a Cisco UCM or CUC device in Automate:   
   
   * Creates a full pull data sync instance, which will perform the initial sync of all data from the device. 
     It is recommended that you manually run the full pull data sync only when necessary. 

     .. raw:: latex

        See Manually run the default data sync in the Core Feature Guide

     .. raw:: html

        <a href="run-data-sync-manually.html">See Manually run the default data sync</a> 

   * Creates a Change Notification Sync type (on the Data Sync page). Manually running the change notification sync is not supported.

   * Creates a scheduled data sync (disabled by default) to execute a data sync every 14 days. This topic 
     describes how to enable this regular sync. 



.. rubric:: Enable the scheduled data sync

1. Log in as provider administrator.
#. Go to the **Sync Scheduling** page. 
#. Choose the schedule instance that matches this naming convention: ``HcsSync-<ip_address>-<device_name>-SCHED``

   For example: ``HcsSync-192.0.2.24-CUCM01-SCHED``

#. Select the **Active** checkbox.
#. On the **Multiple Executions** tab, update the interval, as required.
#. Click **Save**.

   The full data sync executes immediately, and executes again according to the schedule.


.. _create-update-schedule:


Add or edit a schedule
............................


.. _21.3-PB3|EKB-12811:
.. _21.4-PB1|EKB-14801:
.. _21.4-PB2|EKB-6630:


.. tip:: 

   :ref:`use-action-search-to-navigate-automate`


This procedure displays and edits existing schedules, and adds a new schedule.

.. note::

   Automate also provides a tool to deactivate and reactivate schedules in bulk, if required.

   .. raw:: latex

      See Bulk Schedule Activation / Deactivation in the Core Feature Guide

   .. raw:: html

      <a href="concepts-deactivate-activate-schedules.html">See Bulk Schedule Activation / Deactivation</a> 


1. Log in to the Admin Portal and select the relevant hierarchy.
2. Go to **Sync Scheduling** to open the list view. 
3. View existing schedules in the summary list view, which includes a number of attributes for each schedule. 

   .. note:: 

      Resource attributes are used for filtering when you want to choose a resource.

4. Choose an option: 

   * To edit a schedule, click on the relevant schedule to open its configuration page. Make the 
     changes you require, then click **Save**.  
   * To add a new schedule, click the Plus (+) icon to add a new record. Go to the next step to 
     configure the schedule.

5. Configure the schedule. 

   The table describes sync schedule settings on the **Details** tab/panel:

   .. tabularcolumns:: |p{5cm}|p{10cm}|

   +-------------------------------+-------------------------------------------------------------------+
   | Setting                       | Description                                                       |
   +===============================+===================================================================+
   | Schedule Name                 | The name of the schedule.                                         | 
   +-------------------------------+-------------------------------------------------------------------+
   | Last Executed (UTC Time)      | Read-only. Displays the last time this schedule executed. The     |
   |                               | value is always stored and shown in UTC, regardless of the        |
   |                               | execution timezone configured for the schedule.                   |
   +-------------------------------+-------------------------------------------------------------------+
   | Owner                         | The schedule owner. The user who created this schedule. Read-only |
   |                               | for existing schedules.                                           |
   +-------------------------------+-------------------------------------------------------------------+ 
   | Schedule Type                 | Mandatory. Select the schedule type. Either Single Execution or   | 
   |                               | Multi Execution.                                                  |
   |                               |                                                                   |
   |                               | See below for the configurable settings for either single         | 
   |                               | execution or multi execution.                                     |
   +-------------------------------+-------------------------------------------------------------------+
   | Active                        | This checkbox defines whether the scheduled sync is enabled       |
   |                               | (active) or disabled.                                             |
   |                               |                                                                   |
   |                               | Clear the checkbox to disable the sync schedule.                  |
   |                               |                                                                   |
   |                               | If you're enabling the sync schedule and there is a "next         |
   |                               | execution" in the past, the sync executes immediately when you    |
   |                               | save. To prevent the execution of this past sync schedule, select |
   |                               | **Skip execution on activation**.                                 |
   +-------------------------------+-------------------------------------------------------------------+
   | Skip execution on activation  | Prevents the execution of a "next execution" in the past if       |
   |                               | you're choosing to enable the schedule now.                       |
   |                               |                                                                   |
   |                               | Selecting this option prevents a situation where, for example,    |
   |                               | you wish to pause the execution of scheduled syncs for a period,  |
   |                               | perhaps to perform an upgrade. Post-upgrade, when activating the  |
   |                               | schedule, a number of pending syncs may execute immediately. This | 
   |                               | setting clears pending scheduled syncs so that the schedule       |
   |                               | executes again only at the next scheduled execution time, after   |
   |                               | the schedule is set to "active".                                  |                                  
   +-------------------------------+-------------------------------------------------------------------+
   | Scheduled resources           | Mandatory. Displays only when **Active** is selected.             |
   |                               |                                                                   | 
   |                               | Adds one or more scheduled resources. Configure the following:    | 
   |                               |                                                                   |
   |                               | * Click the Plus icon (+) to add a scheduled resource.            |
   |                               | * Select the action, typically, Execute.                          |
   |                               |                                                                   | 
   |                               |   You can schedule one or more actions or one or more resource    |
   |                               |   types, and choose resource attributes for each.                 |
   |                               | * Choose the resource type (resources that can be executed, for   |
   |                               |   example, ``data/DataSync``).                                    |
   |                               | * Choose the resource attribute to filter on when choosing the    |
   |                               |   resource type, which is typically ``name``.                     |
   |                               | * At **Resource**, select the value of the resource attribute.    |
   |                               |   For example, if the attribute is ``name``, then the name of the |
   |                               |   resource.                                                       | 
   |                               | * At **Perform Action**, define whether to enable                 |
   |                               |   or disable the resource scheduled action.                       |
   +-------------------------------+-------------------------------------------------------------------+

   The table describes sync schedule settings on the **Multiple Executions** or **Single Execution** tab/panel. 
   The tab/panel that displays depends on the option selected for **Schedule Type**:  

   .. tabularcolumns:: |p{5cm}|p{10cm}|

   +----------------------+--------------------------------------------------------------------------+
   | Schedule Type        | Settings                                                                 |
   +======================+==========================================================================+
   | Single Execution     | * At **Execution Date and Time**, choose a date and time from the        |
   |                      |   calendar date/time picker.                                             |
   |                      | * Choose the execution timezone.                                         |
   +----------------------+--------------------------------------------------------------------------+
   | Multiple Executions  | Choose one or more of the following options:                             |
   |                      |                                                                          |
   |                      | * Use Specific Executions                                                |
   |                      | * Use Calendar Executions                                                |
   |                      | * Use Timed Executions                                                   |
   |                      |                                                                          |
   |                      | Configure settings for the options you selected.                         |
   |                      |                                                                          |
   |                      | When choosing two or more options, the first scheduled time takes        |
   |                      | priority.                                                                |
   |                      |                                                                          |
   |                      | If a schedule is in a state where the last executed and next execution   | 
   |                      | time are equal, the next execution time is recalculated to ensure its    |
   |                      | execution.                                                               |
   |                      |                                                                          |
   |                      | .. note::                                                                |
   |                      |                                                                          |
   |                      |    If you don't select one of these options, it is treated as disabled.  |
   |                      |    You do not need to toggle an option on and off to make the schedule   |
   |                      |    run. Select only the options you intend to use.                       |
   +----------------------+--------------------------------------------------------------------------+

6. Click **Save** to create (or update) the schedule.

   The schedule you added (or updated) displays in the **Scheduling** list view.

   * Schedules run based on the selected Multiple Executions options. Options that are not selected are 
     considered *off*.
   * You do not need to enable **Use Specific Executions** for schedules to run when using **Use Timed Executions** 
     or **Use Calendar Executions**.

Troubleshooting schedules
............................

* If a schedule appears in the list and **Last Executed (UTC Time)** updates, but no corresponding transaction 
  runs, ensure that at least one **Multiple Executions** option (**Specific**, **Calendar**, or **Timed**) 
  is selected and the schedule is *active*. 
* For older deployments (pre-25.4), if you previously relied on toggling **Use Specific Executions** to make 
  schedules run, this is no longer required in current releases.



