World is now on Opti ID! Learn more

KhurramKhang
Oct 14, 2014
  5293
(0 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

Please login to comment.
Latest blogs
Make Global Assets Site- and Language-Aware at Indexing Time

I had a support case the other day with a question around search on global assets on a multisite. This is the result of that investigation. This co...

dada | Jun 26, 2025

The remote server returned an error: (400) Bad Request – when configuring Azure Storage for an older Optimizely CMS site

How to fix a strange issue that occurred when I moved editor-uploaded files for some old Optimizely CMS 11 solutions to Azure Storage.

Tomas Hensrud Gulla | Jun 26, 2025 |

Enable Opal AI for your Optimizely products

Learn how to enable Opal AI, and meet your infinite workforce.

Tomas Hensrud Gulla | Jun 25, 2025 |

Deploying to Optimizely Frontend Hosting: A Practical Guide

Optimizely Frontend Hosting is a cloud-based solution for deploying headless frontend applications - currently supporting only Next.js projects. It...

Szymon Uryga | Jun 25, 2025

World on Opti ID

We're excited to announce that world.optimizely.com is now integrated with Opti ID! What does this mean for you? New Users:  You can now log in wit...

Patrick Lam | Jun 22, 2025

Avoid Scandinavian Letters in File Names in Optimizely CMS

Discover how Scandinavian letters in file names can break media in Optimizely CMS—and learn a simple code fix to automatically sanitize uploads for...

Henning Sjørbotten | Jun 19, 2025 |