Try our conversational search powered by Generative AI!

K Khan
Oct 14, 2014
  6762
(2 votes)

EPiServer Schedule Jobs (EPIServer 7.5+) FAQs

Schedule Job is a very useful feature to run some functionality periodically.

Q: Do we need scheduler services to run Schedule Jobs?


A: NO, scheduler service have been removed now. scheduled jobs are not executed in the Scheduler Service, but is executed on the site. In previous versions Scheduler service was responsible to keep track on when a job should execute and then make a request to the site to execute the job. This has now been chnaged so the site itself keeps track on when a job should execute and when that is time it calls the specific job.

Q: Will Schedule Job run if site is Down?


A: No, as site runs schedule job.

Q: How a scheduled job is called?


A: During initialization a check is performed against the database for which jobs that are about to be executed. A Timer will then be setup so a callback is executed when the job is to be run. Execute on the job will then be called on a worker thread.

Q: Is There any diffrence between runng the job manually or scheduling that?


A: scheduled jobs are not executed on a web request. Therfore under Schedule Job HttpContext.Current will be null, Code will not have any user rights during run. The manual trigger will cause the task to run with the currently logged in user’s account and with access to that HttpContext.

Q: Can we run job from a specific server in load balancing enviornment?


A: Yes. Each job will just run on one server at the time, it can be any server that perfroms the execution.By default all servers might run the job. How it works is that the first server that starts the specified job will mark in the database that it is executing the job and then the other servers will not start execution at that time. And then at next time it might be so that another server executes the job. If you want more control  it is possible to control which site that should execute scheduled jobs. This is achieved by setting attribute enableScheduler on configuration element /episerver/sites/site/siteSetting to true on the site that should execute the jobs and false on the other sites. In case several sites are configured to run scheduled jobs then each job will be scheduled for execution on all sites.

Q: How to run schedule job under a specific user?

A: Log on with the specified username
example PrincipalInfo.CurrentPrincipal = PrincipalInfo.CreatePrincipal("admin");

If Job Requires specific user permission
if(PrincipalInfo.CurrentPrincipal.Identity.Name == "*****")
{
   //ToDo
}

Disable permission checking for File
Set the BypassAccessCheck to true for IContent(EPiServer.dll)

Q: Can we pass input parameters in EPiServer Job


A: https://blog.mathiaskunto.com/2012/02/13/supplying-episerver-scheduled-jobs-with-parameters-through-admin-mode/

Q: How to implement a schedule job?


A: To implement a scheduled job you need to have a class marked with ScheduledPlugInAttribute. The recommendation is to inherit base class EPiServer.BaseLibrary.Scheduling.JobBase, if the class does not inherit the baseclass it needs to have a static method named "Execute" without parameters that return a string.
[ScheduledPlugIn(DisplayName = "Remove Unrelated Content Resources", LanguagePath = "/admin/databasejob/contentassetscleanupjob", HelpFile = "contentassetscleanupjob", DefaultEnabled = true, InitialTime = "1.1:0:0", IntervalLength = 1, IntervalType = ScheduledIntervalType.Weeks)]
    public class CleanUnusedAssetsFoldersJob : JobBase
    {
        protected override void OnStatusChanged(string statusMessage)
        {
            base.OnStatusChanged(statusMessage);
        }

        public override void Stop()
        {
            //ToDo
        }
 
        public override string Execute()
        {
            return "Job called"; 
        }
   }

Q: Can we get a list of schedule jobs programatically?


A: var plugIns = PlugInLocator.Search(new ScheduledPlugInAttribute()).ToList();

Oct 14, 2014

Comments

valdis
valdis Oct 20, 2014 03:12 PM

I've heard a nice plugin that shows all jobs in the grid in UI :)
https://github.com/valdisiljuconoks/TechFellow.ScheduledJobOverview

K Khan
K Khan Oct 20, 2014 04:05 PM

Q: Any nice plugin that shows all jobs in the grid in UI?
A: Yes, Valdis have done one for us :),
Thanks V

Please login to comment.
Latest blogs
Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog

Azure AI Language – Abstractive Summarisation in Optimizely CMS

In this article, I show how the abstraction summarisation feature provided by the Azure AI Language platform, can be used within Optimizely CMS to...

Anil Patel | Apr 18, 2024 | Syndicated blog

Fix your Search & Navigation (Find) indexing job, please

Once upon a time, a colleague asked me to look into a customer database with weird spikes in database log usage. (You might start to wonder why I a...

Quan Mai | Apr 17, 2024 | Syndicated blog