Sitecore : Adding schedule jobs via agents

This is a really short and sweet post. Sometimes you have to add scheduled jobs to query sitecore items at regular intervals and perform some custom logic.

The easiest way to do it is by adding your code as an agent to the web.config and setting up the interval

First, create your custom class, this could either be within the main website or a separate class library project something like

namespace  Website.AgentsNamespace
public class MyAgentClass
   public static void Run()
     //add your custom logic here
     //call sitecore, services, database whatever
     //its up to you


Compile and make sure there are no bugs.

Navigate to web.config and find


node. Add your class as an agent and set the time interval like

<agent type="[name.of.your.class.including.namespace], []" method="Run" interval="00:05:00" />

Thats it, job done.

Check the logs, and see when sitecor adds the job to scheduler.