Monitor Windows scheduled tasks

Windows scheduled task monitoring is easy with Cronitor. By updating your scheduled action to ping Cronitor before and after your task you'll gain visibility with a web dashboard and receive alerts of any noncompliance with the schedule, including:

  • The job does not run when expected
  • The job runs for longer than expected

Creating a scheduled task monitor

Monitoring scheduled tasks can be completed in just a few minutes, no coding required.

  1. First, determine the frequency of the scheduled task. The schedule is displayed in the interface. In this example, the task runs every 2 minutes. For tasks with complicated schedules or multiple schedules, please contact support to discuss implementation options.
  2. From your dashboard, click the button to create a new monitor and select Heartbeat
  3. Add a "Complete endpoint not pinged in 2 minutes" rule. Optionally, add a "Ran for longer than" rule to identify tasks that run longer than expected.
  4. Add at least one notification method across Email, SMS, Slack, Hipchat, PagerDuty, etc
  5. Give the monitor a descriptive name like Offsite Backup and add optional tags or notes
  6. Save the monitor and you will be given a unique ping URL.

Your new monitor is created in a paused state; monitoring will not begin until the first ping is received.

Integrating your scheduled task monitor

On your server, you will need to create a new .bat file that will be used to run your existing scheduled task command and report the status to Cronitor:

  1. Create or select a folder to contain .bat files for each scheduled task you wish to monitor.
  2. We recommend using the open source Wget for Windows to make Cronitor ping requests. Download the 32 or 64bit executable into the folder from the previous step.
  3. Create a new .bat file using the template below. Update the appropriate path to wget64.exe and the UNIQUE-URL-CODE provided by Cronitor when your monitor was created.
    @echo off
    set "code=UNIQUE-URL-CODE"
    C:\ScheduledTasks\wget64.exe -q https://cronitor.link/%code%/run
    SCHEDULED-TASK-ACTION
    C:\ScheduledTasks\wget64.exe -q https://cronitor.link/%code%/complete
  4. From the Task Scheduler, copy the scheduled task action into the .bat script. To find this, right click the desired scheduled task, select Properties, select Actions, select the first action listed, click "Edit", and then copy both the command itself and any arguments listed to the same line in your .bat script. In the example screenshot below, you would replace SCHEDULED-TASK-ACTION in your bat script with C:\app\bin\collect-stats PRODUCTION. If your scheduled task has multiple actions listed, repeat this step for each action.
  5. If your Scheduled Task does not run as an administrator, ensure the RunAs user can execute the recently created .bat file.
  6. Update your task action to invoke the newly created .bat file:
  7. If possible, run your task manually from the Task Scheduler to ensure that it works properly.