I have an automated script that pulls backups from my website to my local computer. This script could fail; once my server was down, another time I accidentally moved my script.
How do I make Windows Task Scheduler tell me with the script fails (or doesn't run/not found)?
I don't care if a prompt comes up, an email or something that appears on my desktop. I want to be notified if something goes wrong. On my server, crontab emails me about errors - which is great. I want something like that on my windows 7 local computer.
Answer
When a scheduled task fails to start, an event is written to the TaskScheduler event log:
Note: The Task Scheduler log is located at (under Administrative Tools)
Computer Management
System Tools
Event Viewer
Application and Services Logs
Microsoft
Windows
Task Scheduler
Operational
Windows lets you trigger scheduled tasks to start when a variety of events happen, e.g.:
- time of day
- system startup
- user login
- event recorded in event log
Armed with this knowledge, you can create a scheduled task that that runs when your scheduled task fails:
This scheduled task's action can then be set to something that sends you an alert - in your choice of methods (e.g. triggers a shutdown). You might just want it to send an e-mail:
This is how Windows handles everything. You can see many diagnostic tasks that trigger on an event appearing in the log. e.g. when an IP address conflict is detected, an event is written to the log:
- Log: System
- Source: Tcpip
- Event ID: 4198
A scheduled task triggers on this event, and runs a program to tell you about it and to fix it. Keep in mind that the event id is not specific to just one task. Any task that generates the event 203 - Action failed to start, will trigger this task.
No comments:
Post a Comment