Starting at 10.8.1, you can create tasks to schedule the automated execution of a notebook. Each time your notebook is executed according to the schedule you set, the site opens a new container and runs the notebook without user control.
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 per minute to once every five 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 your notebook
The scheduler offers the option to insert parameters as a new cell at execution time, such as account credentials or variables to define.
The operation uses the Tags cell toolbar option, which allows you to create and manage tags for each cell in the notebook workspace. You can change the cell toolbar options by clicking View and choosing Cell Toolbar.
You can designate the place in the notebook where this new cell is added by adding the tag injected-parameters to a cell in your notebook. The new cell is inserted after this cell. Only one cell with the injected-parameters tag is recognized by the operation.
Considerations for your 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 your 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 your notebook does not contain any content that will stop the notebook from completing.
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 your notebook is ready, you can create a task to schedule its execution. Using the Tasks pane in the notebook editor, you can create one or multiple tasks to automate execution of the notebook and specify the task's schedule.
- Save your notebook with a title, if you haven't already.
The Tasks button becomes available in the top ribbon of the notebook editor.
- 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.
- Provide a title in the Title text box to describe your task schedule, such as Weekly data cleaning run.
- If there are parameters you want to add into the notebook when it is executed 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.
- Click Next to move to the Set task schedule details page.
Here, you can specify the particular schedule for this task.
Tip:When you change the value for Repeat Every, the options below change to fit that denomination. For example, if you choose Repeat Every Day, check boxes appear for each day of the week.
- If you want to update the notebook with the results of each executed run, keep the Update Item on Completion option selected. If you do not want the notebook to be automatically updated, deselect the option.
- When you are satisfied with your title, optional parameters, and task schedule, click Create Task.
The task is active and executes the notebook according to the schedule you've set.
If you want to have multiple schedules, perhaps with different parameters inserted, you can create more tasks for the notebook using the same workflow.
Work with existing tasks
Once you have created a task for your 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.
- From the top ribbon of the notebook editor, click Tasks.
- In the Scheduled Tasks section, find the task that you want to work with.
- Click Actions next to the task and do any of the following:
- Click Details to review the results of each individual run of the task.
- 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.
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 task runs.
Changing ownership of a notebook also changes the ownership of that notebook's tasks. The tasks are transferred to the new user in a disabled 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.