Skip to main content

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.

Note

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

  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
  2. In Task Trigger, select When the computer starts.

  3. In Action, select Start a program.

  4. 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.

  5. In Summary, select Open the Properties dialog for this task when I click Finish.

  6. Select Finish. Note that you can also modify properties later from the main window.

  7. On the General tab, select Run whether user is logged on or not.

  8. On the Settings tab, clear Stop the task if it runs longer than and, optionally, select If the task fails, restart every:.

  9. Select OK and if prompted, enter the password for the user.

  10. 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… *.