Abe Miessler
Abe Miessler

Reputation: 85036

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?

Upvotes: 6

Views: 1886

Answers (5)

user933166
user933166

Reputation:

I have had a lot of success with using the task scheduler. It has a lot of customization that borders on intimidating. I would give that a shot.

Upvotes: 2

Nicholas Carey
Nicholas Carey

Reputation: 74177

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.

Upvotes: 3

bigtlb
bigtlb

Reputation: 1572

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

Upvotes: 11

khr055
khr055

Reputation: 29032

I've only done this with a task scheduler that was running on the server that I was working with. I just set it up to run at a random time in between 11:30 and 12:30. Kelloti's idea is probably a lot more impressive.

Upvotes: 1

kelloti
kelloti

Reputation: 8951

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

Upvotes: 6

Related Questions