0

I have a site that I'm working on. Say I need something to run every... say... 30 minutes, how would I get just a simple thing to run like that?

EDIT

I'll be hosting this online with another company. This is why I am not making it as a separate scheduled program.

6
  • 4
    First I would say a website is not a right choice to run periodic background jobs use a windows service. If you still want to use a web site for this purpose, start a thread in the application_start event handler of Global.asax which goes to sleep for every 30 mins and then invokes some code Commented Aug 4, 2011 at 21:59
  • What is "something"? If It is a script, what script it is? Commented Aug 4, 2011 at 22:00
  • @Cybernate, it isn't just for anything, the site is an actual site ;) sorry about the vagueness. Post this as an answer I guess :) Commented Aug 4, 2011 at 22:01
  • If you want to do something periodically - you can consider that executed as a scheduled task - support.microsoft.com/kb/308569. Commented Aug 4, 2011 at 22:02
  • @ydobonmai, say I need to change a database value or something. Commented Aug 4, 2011 at 22:02

3 Answers 3

4

If you need a process to be run at pre-defined intervals you might be better off using the windows task scheduler, or to create a windows service with a timer. ASP.NET applications aren't ideal for doing this sort of thing, since they are vulnerable to restarts and so you can't guarantee that the process will run at the given interval.

Sign up to request clarification or add additional context in comments.

Comments

2

Windows scheduled tasks and services are ideal for this but if you want to run database queries at specified times then I would suggest using SQL Server Agent if you have access to this.

Comments

1

I don't know of any way to reliably do this using ASP.NET. My understanding is: after a certain period of inactivity, IIS will unload your website/webspp from memory. If that happens, your periodic job very likely won't execute, regardless of what technique you used to configure it.

You could, of course, set up some kind of automated system on your own, which occasionally pings your site to keep it from being unloaded. But if you're doing that anyway, well you could just set it up to do the desired operation at the desired interval. :)

1 Comment

"...a worker process will shut down after a specified period of inactivity. The default value for idle time-out is 20 minutes." technet.microsoft.com/en-us/library/cc771956%28WS.10%29.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.