📚 Product Knowledge
Scheduled Jobs Admin
📖 Docs

Scheduled Jobs – Admin View - Optimizely CMS 12

Exam Area: Area 1 – Product Knowledge (15%) Reference: https://docs.developers.optimizely.com/content-management-system/docs/scheduled-jobs


1. Accessing Scheduled Jobs in Admin

/episerver/cms/admin → Scheduled Jobs

The Scheduled Jobs admin page lists all registered scheduled jobs (both built-in and custom).


2. Managing Jobs via Admin UI

For each job, the admin panel shows:

FieldDescription
NameDisplay name of the job
StatusIdle / Running / Failed
Last runTimestamp of last execution
Next runCalculated next execution time
IntervalHow often the job runs
EnabledWhether the job is active

Actions available:


3. Built-in Scheduled Jobs

JobPurpose
Archive functionArchives old content versions beyond configured limit
Clear Thumbnail PropertiesRegenerates image thumbnails
Fetch data from Remote SitesPulls content from mirroring sources
Link validationScans for broken internal/external links
Mirroring serviceMirrors content to another CMS instance
Rebuild global secondary indexRebuilds the global search index
Remove abandoned BLOBsDeletes orphaned binary files (media without content items)
Remove old content versionsPrunes old saved versions per content item
Remove old temporary BLOBsCleans up temporary upload files
SubscriptionSends notification emails for subscribed content
Crawl for link changesUpdates link database

4. Execution Log

Each job stores the last execution result as a status message. View it in Admin:

Admin → Scheduled Jobs → Click job name → View log
  Shows:
    - Start time
    - End time
    - Status (Success / Failed)
    - Output message (returned by Execute())
    - Exception details (if failed)

5. Custom Scheduled Job (Code Reference)

See 04_Framework_Components/03_scheduled_jobs_dev.md for implementation details.

// Minimal example
[ScheduledPlugIn(
    DisplayName = "Refresh Product Cache",
    GUID        = "E5C9D2F4-1234-5678-ABCD-0011223344FF",
    DefaultIntervalType = ScheduledIntervalType.Hours,
    DefaultInterval = 6)]
public class RefreshProductCacheJob : ScheduledJobBase
{
    private bool _stopSignaled;

    public RefreshProductCacheJob()
    {
        IsStoppable = true;
    }

    public override void Stop() => _stopSignaled = true;

    public override string Execute()
    {
        var count = 0;
        foreach (var product in GetProducts())
        {
            if (_stopSignaled) return $"Stopped after {count} products.";
            RefreshCache(product);
            count++;
        }
        return $"Refreshed cache for {count} products.";
    }
}

6. Interval Types

public enum ScheduledIntervalType
{
    None,       // No automatic scheduling
    Minutes,
    Hours,
    Days,
    Weeks,
    Months
}

7. Load-balanced Environments

In a multi-server (load-balanced) environment, scheduled jobs run on one server at a time to prevent duplicate execution:

Server A: Running job ─────── (leader)
Server B: Waiting ─────────── (follower, skips execution)
Server C: Waiting ─────────── (follower, skips execution)

8. Triggering a Job Programmatically

// Run a scheduled job from code (e.g. from a controller action)
public class AdminController : Controller
{
    private readonly IScheduledJobRepository _jobRepository;
    private readonly IScheduledJobExecutor   _jobExecutor;

    public AdminController(
        IScheduledJobRepository jobRepository,
        IScheduledJobExecutor jobExecutor)
    {
        _jobRepository = jobRepository;
        _jobExecutor   = jobExecutor;
    }

    public async Task<IActionResult> RunJob(Guid jobGuid)
    {
        var job = _jobRepository.Get(jobGuid);
        if (job == null) return NotFound();

        await _jobExecutor.StartAsync(job, new JobExecutionOptions
        {
            Trigger = ScheduledJobTrigger.User
        });

        return Ok($"Job '{job.Name}' started.");
    }
}

Review Questions

  1. What button lets an admin run a scheduled job immediately? (Run Once / Run manually)
  2. In a load-balanced environment, how does CMS prevent duplicate job execution? (SQL-based leader election — only one server runs the job)
  3. What enum controls how often a job runs? (ScheduledIntervalType)
  4. What interface is used to trigger a job from code? (IScheduledJobExecutor)
  5. What does the "Remove abandoned BLOBs" job do? (Deletes media binary files that no longer have an associated content item)