Skip to main content

Jobs and Scheduling

Overview

Jobs enable scheduled execution of synchronizations and other tasks within OpenConnector. Each job is configured with a cron expression that determines when it runs. The Nextcloud background job system (IJobList) drives execution. All job runs are logged with their outcome, duration, and any errors.

Job Configuration

FieldDescription
nameHuman-readable job name
slugURL-friendly unique identifier
synchronizationIdSynchronization to run (required for sync jobs)
scheduleCron expression (e.g. 0 * * * * for hourly)
isEnabledWhether the job is active
forceIf true, skip change detection on each run
maxRetriesNumber of retry attempts on failure
nextRunTimestamp of the next scheduled execution
lastRunTimestamp of the last execution

Cron Expressions

Jobs use standard 5-field cron syntax:

┌───────────── minute (0–59)
│ ┌─────────── hour (0–23)
│ │ ┌───────── day of month (1–31)
│ │ │ ┌─────── month (1–12)
│ │ │ │ ┌───── day of week (0–7, 0 and 7 = Sunday)
│ │ │ │ │
* * * * *

Common schedules:

ExpressionFrequency
* * * * *Every minute
0 * * * *Every hour
0 0 * * *Daily at midnight
0 6 * * 1Weekly on Monday at 06:00
*/15 * * * *Every 15 minutes

Job Execution

When a job fires, JobService resolves the associated synchronization and delegates to SynchronizationService.synchronize(). The force flag on the job is passed through, overriding change detection if set.

Job Logging

Every job execution produces a log entry with:

  • Start and end timestamps
  • Execution duration
  • Result (success, error, skipped)
  • Number of objects processed
  • Error message and stack trace (on failure)

Logs are accessible in the OpenConnector UI under the Logs section and via GET /api/logs?jobId={id}.

Log Cleanup

OpenConnector automatically purges old job log entries to prevent unbounded storage growth. Retention periods are configurable:

SettingDefaultDescription
Success log retention30 daysKeep successful run logs
Error log retention90 daysKeep failed run logs

Cleanup runs as part of the background job cycle.

Implementation

  • lib/Service/JobService.php — Job execution and log writing
  • lib/Controller/JobsController.php — REST CRUD API
  • lib/Db/Job.php — Entity
  • lib/Db/JobMapper.php — Database mapper
  • lib/Db/JobLog.php — Log entity
  • lib/Db/JobLogMapper.php — Log mapper