Sitecore provides a framework for the process scheduling out of the box. This functionality is often used in the scenarios when it is important to automate a background process of any sort such as content sync or import, cleanup, etc. So it is critical to understand the underlying logic of this process which is really straightforward, but may be unknown for the newbies.
The Sitecore Scheduler is basically a background process that is started with the sleep interval defined in the <frequency> section.
The skeleton of the <scheduling> section looks like this:
3: <agent ...>
Within the execution of the Scheduler, it queries the inner contents for the agents defined there and adds to the queue only those agents which marked as "due". An agent is considered "due" if the value of the "interval" parameter is less than the timeframe of the last execution. In other words, if the agent was run 4 minutes ago last time (the frequency is set to 1 minute for example) and the interval parameter of the agent is 5 minutes, it is obvious that it will not run this time. So you may find it convenient to think about the global frequency parameters as an external loop.
An agent is considered disabled if the "interval" parameter is set to zero seconds ("00:00:00").
After the logic is able to retrieve a list of agents marked as "due", each agent is executed as a job process and the last run date is updated.
Here are some examples of what is expected in two different configurations below:
- The case when "MyAgent" will not be executed each 10 seconds due to the bigger value in the "frequency" parameter. The agent will still be executed each 10 minutes. This is a common configuration issue
3: <agent type="MyProj.MyAgent, MyDLL" method="Run" interval="00:00:10"/>
- In this case the MyAgent code will be executed roughly each 10 minutes as specified in "interval" but will be triggered for the "IsDue" check each 10 seconds:
3: <agent type="MyProj.MyAgent, MyDLL" method="Run" interval="00:10:00"/>
Hope this makes sense.