Click here to Skip to main content
Sign Up to vote bad
good
See more: Scheduler
I need to check a daily log file for errors.   I have created a C# class with one method that checks the file and sends an e-mail with the answer.   I want the system to run this class automatically every night.
 
Any help would be greatly appreciated.
Posted 5 Oct '11 - 4:32


2 solutions

The easiest an simplest way would be to employ the Windows Task Scheduler[^] service.
 
Build your class into a console application, then use the Task Scheduler to schedule it. This can be done using the GUI (Control Panel → Administrative Tools → Task Scheduler), or at the command line using at[^] or schtasks[^]. The latter is much more flexible.
 
If you would like to do this programatically, you want to develop a Windows NT Service[^]. This is a much bigger task.
  Permalink  
Comments
SAKryukov - 5 Oct '11 - 11:22
Agree, using the Task Scheduler service is probably the best way, my 5. Writing a whole Windows Service for this task could be a big overkill for this particular problem, good to mention though. --SA
Create a console app project using your class and schedule it on your server.
 
Here you will find an guide on how to schedule a task:
http://support.microsoft.com/kb/308569[^]
 
And here you can start with a creating a console app:
 
http://msdn.microsoft.com/en-us/library/0wc2kk78(v=vs.90).aspx[^]
 

Cheers!
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 206
1 Richard MacCutchan 145
2 Tadit Dash 140
3 Sergey Alexandrovich Kryukov 135
4 Santhosh G_ 125
0 Sergey Alexandrovich Kryukov 10,294
1 OriginalGriff 7,955
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,159


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 5 Oct 2011
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid