Watch your Windows scheduled tasks.
Task Scheduler shows the last result only to someone who opens it. Add one line to the task’s PowerShell script, and Runbell tells you when a task didn’t run or failed.
Up
export-invoices
- Schedule
0 7 * * 1-5weekdays at 07:00- Grace period
- 30 minutes
- Alerts
- Email and Microsoft Teams
What goes wrong without anyone noticing
- The task stops running
- After an update, or a password change for the account that runs it, the task is skipped.
- The machine is asleep or off
- The task waits for a moment that never comes.
- The script fails
- The exit code is in the History tab, and nobody looks at it.
Set it up
-
Create a check
Use the schedule
0 7 * * 1-5and a grace period of 30 minutes, in the time zone the job runs in. -
Add the ping
Wrap the job in try and catch: ping on success, ping
/failwith the error message on failure. -
Choose who hears about it
Connect email, Slack, Telegram, SMS or any of the other channels to the project.
C:\Jobs\run-export.ps1
$url = "https://runbell.app/ping/your-check-id"
try {
& C:\Jobs\export-invoices.ps1
Invoke-RestMethod $url -TimeoutSec 10
} catch {
Invoke-RestMethod "$url/fail" -Method Post -Body $_.Exception.Message -TimeoutSec 10
}
Tips
- Set the check’s time zone to the server’s, for example
Asia/Dubai, so the schedules line up. - Send the error message with
/fail, and read it right in the alert. - Batch files can use
curl.exe, which comes with Windows 10 and later.
Questions
Do I need admin rights?
No. The task only needs to reach the internet over HTTPS.
Our servers are behind a proxy. Does it still work?
Yes. Invoke-RestMethod accepts -Proxy, and curl.exe accepts --proxy.
Other jobs to watch
- pg_dump, mysqldump Database backups Know the night a backup fails, not the day you need it.
- crontab Linux cron jobs An alert when a crontab job is late, missing or fails.
- batch/v1 Kubernetes CronJobs Catch the CronJob that never started a pod.
- ETL, Airflow, reports ETL and reports Hear about the pipeline that didn’t finish before the morning meeting.
- certbot, ACME Certificate renewal Find out before an expired certificate does.