Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an automated script that pulls backups from my website to my local computer. Once my server was down, another time i accidentally move my script. How do i make Windows Task Scheduler tell me with the script fails (or doesnt run/not found)? I dont 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.

share|improve this question

3 Answers 3

up vote 31 down vote accepted

When a scheduled task fails to start, an event is written to the TaskScheduler event log:

Note: The Task Scheduler log is located at

 Computer Management
    System Tools
       Event Viewer
          Application and Services Logs
             Microsoft
                Windows
                   Task Scheduler
                      Operational

enter image description here

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:

enter image description here

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:

enter image description here

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.

share|improve this answer
1  
You get the event id from the event log (203 and 103). You can see the event id's in the screenshot (203 and 103). Or i can tell you the event id's: 203 and 103. –  Ian Boyd Feb 23 '11 at 3:20
3  
What do you do if the second task fails!?!? –  William Jackson Jun 1 '12 at 14:06
1  
@WilliamJackson Create an event that shuts down the machine. Someone will definitely be alerted to a problem then. –  Ian Boyd Jun 1 '12 at 17:51
4  
Actually if the 2nd task fails it will launch the 2nd task which will fail which will launch the 2nd task which will fail which will launch the 2nd task which will... you get the idea. I just found this out the hard way =/ –  Rob Penridge Oct 19 '12 at 20:58
1  
This doesn't alert you if a task fails, only if it fails to start. Not quite the same thing. –  jwg Aug 20 '13 at 15:44

Take a look at PushMon. You can create a PushMon URL that will be called at the end of your script. If your script doesn't run because the server was down or the script was moved, you will get notified. You can get notified by email, SMS, phone call, IM and Twitter. This will work for any operating system. This is like Pingdom but for scripts and background tasks.

share|improve this answer
1  
If you add it to the end of your script, and the script is missing (e.g. moved), how is it supposed to get called‽ –  Bob Jun 1 '12 at 14:24
1  
Since the script moved and URL did not get called, then you will get an alert. –  Bienvenido David Jun 1 '12 at 20:27

Using the steps given the blog post below, you can send an error email with contents on the event log. That way you don't need to send a generic email.

http://blogs.technet.com/b/jhoward/archive/2010/06/16/getting-event-log-contents-by-email-on-an-event-log-trigger.aspx

share|improve this answer
1  
Can you summarize what the blog post says in your answer in case the link goes dead? –  jonsca Aug 8 '13 at 20:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.