Setup for Scheduler Tasks

27-Aug-2024 · Sunny Wong

What is a Scheduler Task?

A scheduler task automates the execution of tasks at specific intervals. In a Windows environment, this is achieved using the "Windows Task Scheduler".

When Do I Need Scheduler Tasks?

You might need scheduler tasks for scenarios like sending regular email notifications or performing data import/export every morning at 8 AM. Since the Backstage server lacks a comprehensive built-in schedule for timed tasks, we recommend scheduling them externally.

Steps to Set Up a Task

  1. Create a New Task:
    • Access the Backstage admin portal.
    • Click "Automation Rule" in the top-right corner.
    • Click "Add New".
    • For "Event Name," enter "-".
    • Provide appropriate values for "Name" and "Description," such as "my-schedule-task-001" and "this task runs my scheduled task of code 001."
    • Paste the appropriate formula in "Action Formula" (provided by support).
    • Click "Save".
    • Refresh the page and select the task you just created.
    • Note the URL format, e.g., http://your-host-name/automationRule/edit/some-random-id.
    • Copy this URL for the next step.

Steps to Set Up a PowerShell Script

  1. Copy the URL from the previous step.
  2. Open a text editor or PowerShell using "Run ISE as administrator".
  3. Paste the line:
    Invoke-RestMethod -Method "Post" -Uri "http://your-host-name/api/tasks/run?taskId=some-random-id"
  4. Save the script in a suitable folder as a .ps1 file, e.g., C:\your-folder\script.ps1.

Steps to Set Up a Scheduler Task

  1. Connect to the computer hosting Backstage.
  2. Open "Windows Task Scheduler" from the menu.
  3. In the "Actions" panel, click "Create Task".
  4. Under the "General" tab, enter appropriate values for "Name" and "Description".
    • In "Security options," select "Run whether user is logged on or not" and "Run with highest privileges".
  5. Under the "Triggers" tab, click "New" and set it to "daily/weekly/monthly" as desired, then click "OK".
  6. Under the "Actions" tab, click "New". In "Program/script," type "powershell". In "Add arguments (optional)", enter -File "C:\your-folder\script.ps1", then click "OK".
  7. Click "OK" again. You may need to enter a user password.
  8. In the Task Scheduler Library, your new task will appear in the task list.

Important Note

Admin privileges may be required to run the PowerShell script. Consult your IT support and refer to this Stack Overflow discussion.


Updatedat: 2022-08-27