Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement a nightly process in .NET?

I have a set of tasks that I would like to execute every night.

These tasks include, in order, querying a database, moving and then renaming some images and updating a database table. My first thought had been to create a SQL Server job and use xp_cmdshell to move the files but after a bit of research I decided against it.

What is the best way to implement this as a .NET application? Should I create a Windows service? A console application that is scheduled to run once per night? Some other cool way that I don't even know about?

like image 794
Abe Miessler Avatar asked Feb 02 '11 22:02

Abe Miessler


3 Answers

I usually just do this as a scheduled console application. Maybe I'm boring...

like image 194
bigtlb Avatar answered Oct 21 '22 11:10

bigtlb


The cool way you are looking for is Quartz.NET. It's basically cron jobs for .NET.

like image 42
kelloti Avatar answered Oct 21 '22 10:10

kelloti


I usually do this sort of thing as a scheduled task. If it's a .Net/C# console app, don't write to Console.Out or Console.Error (the scheduled tasks run pretty much headless). Instead use log4net and configure an appender to write to a log file. You configure another appender to log errors to the windows event log as well.

Of course, the faster, easier way would be to write your job as perl script rather than as compiled code, and schedule that.

like image 41
Nicholas Carey Avatar answered Oct 21 '22 11:10

Nicholas Carey