Skip to main content

Run extractors in Windows Task Scheduler

Some of the Cognite extractors are distributed as a Windows service or as executable files. This article explains how you can run the Cognite extractors in Windows 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.

Note

You need interactive sign-in 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

  1. Unzip the extractor in an installation directory. For example: C:\Cognite\opcua-extractor.
  2. Create a working directory for the source system. For example: AControlSystem.
  3. Open the config folder and configure config.yml based on the example file found in the same folder.

Create a task

  1. Open the Task Scheduler, select Create Basic Task > enter a name > select Next.
Create a basic task
  1. In Task Trigger, select When the computer starts.
  2. In Action, select Start a program.
  3. 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.
  4. In Summary, select Open the Properties dialog for this task when I click Finish.
  5. Select Finish. Note that you can also modify properties later from the main window.
  6. On the General tab, select Run whether user is logged on or not.
  7. On the Settings tab, clear Stop the task if it runs longer than and, optionally, select If the task fails, restart every:.
  8. Select OK and if prompted, enter the password for the user.
  9. Save the task. The task is now listed under Active tasks in the main window:
Note

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

  1. Under Action, select Properties > Triggers.

  2. Select Edit trigger and configure the schedule settings.

    Tip

    Enable **Stop the task if it runs longer than… **.