You may want to have a geoprocessing model run at a specific time of day, or set the model to run repeatedly at some time interval. Maybe the model takes a long time to run and you want the results to be available at a certain time every day. You can schedule a model to run at a particular time and with a specified frequency using Windows Task Scheduler and a few lines of Python code.
Import a model with ArcPy
For example, the model below compares all current feature classes in a workspace to a backup copy. If there are differences between the current features and the backup copy, the model creates a new backup in a time-stamped folder using the Copy Features tool.
To schedule this model, create a Python script file and use the ImportToolbox function to import the toolbox containing the model. Then add a line of code to execute the model tool with any required model parameters such as myModel in the following example:
The ImportToolbox's alias parameter is recommended only if the toolbox does not have an alias.
Create a task
After creating a Python script file that runs your model tool using ArcPy commands, you can use the Windows Task Scheduler to run the script (and in turn, the model) at a specified time. Search your Windows programs for Task Scheduler and open the program. Click Action > Create Task. On the Create Task dialog box, name the task.
To execute the script file you created with your preferred Python installation, on the Create Task dialog box, click Actions > New. The New Action window appears. For the Program/script option, browse to the python.exe file in your ArcGIS Pro installation folder. This ensures that the script will be able to execute ArcPy functions. The default file path for the version of Python used in ArcGIS Pro is C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe.
For the Add arguments (optional) option in the New Action window, add the path to your script file.
Click OK to close the New Action window.
On the Create Task dialog box, on the Triggers tab, click New to open the New Trigger window. Set the time and regularity you want your model to run.
Click OK to save your trigger and close the New Trigger window.
Models can be scheduled to run when your computer idles, logs on, or starts. To run your model under these conditions, click New Trigger > Begin the Task and choose the option that matches your requirement.
Multiple triggers and conditions offer more control over when a model will run. For example, using the settings below, a model will run daily at 5 p.m. once the computer idles.