Schedule a notebook task

You can create tasks to schedule the automated execution of a notebook. Each time the notebook is run according to the schedule you set, the site opens a new container and runs the notebook without you needing to open the notebook yourself. A maximum of five tasks can be running at the same time across all notebooks you own.

From the Tasks pane in the notebook editor, you can create one or multiple scheduled tasks to run the notebook. You can schedule it to run once in the future or on a recurring basis—from once every 15 minutes to once every 6 months.

If you are preparing a notebook for automated execution, such as on a recurring basis, there are a few things to keep in mind.

Prepare the notebook

You can configure input and output parameters for a notebook. Input parameters correspond to input variables in a notebook that you want to externalize for a scheduled task. When a scheduled task runs, input parameters are inserted into the notebook at the top of the notebook, similar to global variables. This allows you to author generic notebooks and modify the values for input variables at run time.

Task parameters are injected by default into a cell at the beginning of a notebook. Alternatively, you can use the Tags cell option in the toolbar, which allows you to create and manage tags for each cell in the notebook workspace, to create a tag for a cell named injected-parameters. Task parameters are injected into the cell that follows the injected-parameters tag. To enable tags, you can change the cell toolbar options by clicking View, clicking Cell Toolbar, and clicking Tags.

Considerations for content

Other than the parameters cell it can insert, scheduling a notebook does not support any user interaction with notebooks. Avoid adding any content that requires user interaction while the notebook runs, such as clicking a point on a map.

Any credentials or new variables you want added at the time of automated execution must be inserted in the parameters cell, as shown above. Make sure the notebook does not contain any content that will stop the notebook from completing.

Note:

When authoring notebooks, use full paths to directories and files in the workspace directory.

For example, use /arcgis/home/test.gdb instead of home/test.gdb.

Create a task

When the notebook is ready, you can create a task to schedule its run. Using the Tasks pane in the notebook editor, you can create one or multiple tasks to automate runs of the notebook and specify the task's schedule.

  1. Verify that you are signed in with privileges to create and schedule notebooks.
  2. Save the notebook with a title, if you haven't already.

    The Tasks button becomes available in the top ribbon of the notebook editor.

  3. On the top ribbon of the notebook editor, click Tasks.
  4. Click Create Task to open the dialog box.

    Note:
    You can also create tasks from the Tasks tab of the notebook's item details page.

  5. Provide a title in the Title text box to describe the task schedule, such as Weekly data cleaning run.
  6. If you have not previously configured parameters for the notebook and there are parameters you want to add into the notebook when it is run by the task, provide them in the Parameters section. Give a key in the Key setting and its paired value in the Value setting for each parameter, and click Add Parameter to save the parameter.

    Once you have added at least one parameter, the Save Parameters to Notebook option appears. If this option is turned on, the cell inserted with your new parameter is saved to the notebook when it is run.

    If you have previously setup input parameters using the Parameters option, those parameters are automatically populated for the task. You can add, remove, or update any parameters specific to this task. Doing so will not change the default parameters for the notebook configured using the parameters option.

  7. Click Next.
  8. On the Set task schedule details page, specify the schedule for the task.

    Tip:
    When you change the value for Repeat Type, the options below change to fit that denomination. For example, if you choose Week, check boxes appear for each day of the week.

  9. Use the Update Notebook on Completion toggle button to choose to save the notebook after each run. If you want to update the notebook with the results of each run, turn on the toggle button. If you do not want the notebook to be automatically updated, turn off the toggle button.
  10. Optionally, click Advanced to enter the maximum amount of minutes that the task can run.
  11. When you are satisfied with your title, optional parameters, and task schedule, click Create Task.

    The task is active and runs the notebook according to the schedule you've set.

If you want to have multiple schedules, you can create more tasks for the notebook using the same workflow. A maximum of five tasks can be executing at the same time across all notebooks you own. Tasks that are scheduled to start while there are five tasks already in progress are marked as failed.

Work with existing tasks

Once you have created a task for a notebook, you can view the task's details and edit or delete it at any time. You can make changes to tasks from either the Tasks pane of the notebook editor or from the Tasks tab of the notebook's item details page. In both places, you can view all tasks for the notebook with the time each task was created, when it was last modified, and its current status.

  1. Verify that you are signed in with privileges to create notebooks.
  2. From the top ribbon of the notebook editor, click Tasks.
  3. In the Scheduled Tasks section, find the task that you want to work with.
  4. Click Actions Actions next to the task and do any of the following:
    • Click Details to view the details and status of each run of the task. To view the run results, click the Results button. A tasks' status can be one of the following:
      • Succeeded—The task completed successfully.
      • Executing—The task is currently running.
      • Failed—The task failed to run successfully. If a task fails five times, it is completely stopped.
      • Skipped—The task was skipped because a previous run was still executing.
    • Click Edit to change the title, parameters, or schedule of the task.
    • Click Pause to pause an active task. When paused, click Resume to resume the task.
    • Click Delete to remove the task.
      Note:

      Deleting a task also deletes the run history of the task. To preserve an active task's history, consider pausing the task to stop further runs.

Changing ownership of a notebook also changes the ownership of that notebook's tasks. The tasks are transferred to the new user in an inactive state. The new owner can enable the tasks from the Tasks pane of the notebook editor or from the Tasks tab of the notebook's item details page.