Run extractors in Windows Task Scheduler
The Cognite extractors are distributed as a Windows service or as executable files. This article explains how you can run the Cognite extractors inWindows Task Scheduler. This is useful when you need to start the extractor when the machine reboots, restart the extractor if it terminates, or run the extractor on a schedule.
Installing the extractor
Install the extractor in an installation directory where the executable file or Python program and dependencies are stored. The extractor can be instantiated in multiple deployments, for instance, one per source system. Each deployment requires a separate working directory to read configuration files, store state, and write logs.
You need interactive login permissions to execute a task.
Run as a service
The Windows Task Scheduler is an alternative to native Windows services. In this example, we'll use the Task Scheduler to run the OPC UA extractor executable file as a service.
Before you start
- Unzip the extractor in an installation directory. For example:
- Create a working directory for the source system. For example:
- Open the config folder and configure
config.ymlbased on the example file found in the same folder.
Create a task
Open the Task Scheduler, select Create Basic Task > enter a name > select Next.
In Task Trigger, select When the computer starts.
In Action, select Start a program.
In Start a Program, insert the full path to the .exe file in Program/script, and add the working directory in Start in. Enter any command line arguments in Add arguments. For example, for PI extractor version 1.
In Summary, select Open the Properties dialog for this task when I click Finish.
Select Finish. Note that you can also modify properties later from the main window.
On the General tab, select Run whether user is logged on or not.
On the Settings tab, clear Stop the task if it runs longer than and, optionally, select If the task fails, restart every:.
Select OK and if prompted, enter the password for the user.
Save the task. The task is now listed under Active tasks in the main window:
The status Ready indicates that a task is ready to start but not running.
Start a task
To start a task, right-click and select Run, or select Run from the Actions pane.
Run batch extractors on a schedule
Under Action, select Properties > Triggers.
Select Edit trigger and configure the schedule settings.Tip
Enable Stop the task if it runs longer than… *.