简体   繁体   中英

Utility made in C# and scheduled in Task Scheduler is behaving strangely!

I have a C# console application that fetches data from more than 100 servers using SNMP and then writes the same in DB. I have scheduled the same in Windows 2008 R2 server's Task Scheduler and is suppose to run after every 15 min. But the strange part is sometimes it runs and sometimes it don't. If I run it manually then it runs every time. Proper Try Catch is there in the code and mails will be triggered is exception happens, but nothing of that sort is happening. The task process gets created and action completed is happening simultaneously.

I am confused, please suggest what to do!

Does it run for longer then 15 minutes? (So could you be ending up with more than one running, and interfering with each other?)

Look in the Event Log's Application Events to see if any crashes of your program are recorded.

It sounds like the email notifications may not be working on your server, so I'd add some trace into it: Write to a log file the DateTime.Now every time it starts, and perhaps the name of each server as it is processed, and then then exit time. And of course, log the details of any exceptions you want to know about (ideally, add an unhandled exception handler so you can log all exceptions). Then you'll be able to see exactly when it is executing and that it is processing everything properly. This will help diagnose if it is not being run, if it is being run but is failing immediately, or if it is doing a partial run and failing after processing a few servers. Then you can focus in on the point of failure.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM