Monitoring Windows Task Scheduler jobs
20 checks, email and Slack alerts.
Task Scheduler runs a lot of important work on Windows servers: SQL backups, file transfers, report exports, cleanup scripts. Its history view shows results if you go and look, and the "Last Run Result" column is easy to misread. Nobody goes and looks until something is missing.
Why tasks fail quietly
- The account's password changed, and tasks set to "run whether user is logged on or not" stop starting
- The task is set to run only on AC power and the machine is a laptop or VM reporting battery
- "Stop the task if it runs longer than" kills a long run
- The server rebooted during the scheduled time and the task isn't set to run as soon as possible after a missed start
- The script's working directory isn't what it expects, because "Start in" was left blank
- History is disabled, so there's no record at all
Add a heartbeat ping with PowerShell
Wrap the work in a script that pings Ping Clock at the end.
$ErrorActionPreference = "Stop"
$ping = "https://www.pingclock.com/ping/YOUR-CHECK-ID"
try {
Invoke-RestMethod "$ping/start" -TimeoutSec 10 | Out-Null
# ... your job here ...
& "C:\Tools\export.exe" --nightly
if ($LASTEXITCODE -ne 0) { throw "export.exe exited with $LASTEXITCODE" }
Invoke-RestMethod $ping -TimeoutSec 10 | Out-Null
}
catch {
Invoke-RestMethod "$ping/fail" -Method Post -Body $_.Exception.Message -TimeoutSec 10 | Out-Null
exit 1
}
What this gives you:
/startrecords when the run began, so a hung task shows up as "started but never finished"- The plain ping marks success
/failwith the error message marks failure straight away, and on Pro the message appears in the alert$LASTEXITCODEcatches external programs that fail without throwing
Setting up the task
- Action: Program
powershell.exe, arguments-NoProfile -ExecutionPolicy Bypass -File "C:\Scripts\nightly.ps1". - Start in: the script's folder.
- Settings: tick "Run task as soon as possible after a scheduled start is missed".
- Conditions: untick "Start the task only if the computer is on AC power" for servers.
- History: enable all task history in Task Scheduler if it's off.
Choosing the check schedule
Match the task's trigger. For "daily at 01:30", use a cron schedule 30 1 * * * with the server's time zone, for example America/Chicago. Set a grace time to cover the longest normal run.
When PowerShell can't make web requests
Some locked-down servers block outbound HTTP. Options:
- Allow outbound HTTPS to the ping endpoint only
- Use the check's email-in address and send mail through your internal relay with
Send-MailMessageor your mail tool of choice - Ping from a machine that can reach both
Legacy batch files
From a .bat file, Windows 10 and later include curl.exe:
call C:\Scripts\job.bat && curl.exe -fsS -m 10 https://www.pingclock.com/ping/YOUR-CHECK-ID
Questions
Can I monitor tasks across many servers?
Yes. Create one check per task per server and name them clearly. The API on Pro helps when there are many.
Does Ping Clock install an agent on Windows?
No agent. The script makes an HTTPS request, that's all.