# Jobs

The jobs panel shows the available system jobs within the SanteDB server. System jobs are implementations of the `IJob` interface and may be run on a schedule (such as cleaning or maintenance jobs) or might be one off jobs. Jobs are shown with their last execution time and current status.

{% hint style="info" %}
Jobs are run in the background and can execute without blocking other processes. The Jobs panel can be used to see the last time a job was run, its outcome and to manually kickstart the job.
{% endhint %}

The jobs panel summary shows the list of jobs registered on the dCDR or iCDR.

![](https://3421852694-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LZ0_pjgTp_kx4hqTZ3a%2Fuploads%2F23zCpoIey0Vf6UE5fcEU%2Fimage.png?alt=media\&token=7d63bd3a-3b5e-4a55-a853-804028b8ff1f)

The columns for the job indicate:

* Name - The name and description of the job which is represented.
* Schedule / Repeat - Indicates the configured schedule for the job.
* Current State - Shows the current status of the job.
  * Running - The job is currently executing in the background
  * Aborted - The job started, however due to an error it had to stop
  * Not Yet Run - The job has never been run
  * Complete - The job has completed successfully
  * Cancelled - The job was cancelled before it could be completed
* Actions - Allows the administrator to control the job:
  * Run - Run the job immediately
  * Cancel - (if supported) Send a cancellation request to the job
  * Schedule - Modify or set the job's schedule

## Running a Job

When you run a system job you will be prompted to provide any job parameters (if any) which will control the execution of the task.

![](https://3421852694-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LZ0_pjgTp_kx4hqTZ3a%2Fuploads%2FGpdZKK0HfYNwt85poxaF%2Fimage.png?alt=media\&token=ec6a1b35-07e5-4574-8317-2fc76b57396c)

After setting parameters and pressing `Ok` administrators will be asked to confirm the execution of the job.

## Scheduling Jobs

{% hint style="info" %}
This feature is only available in administrative portals > version 2.1.165
{% endhint %}

SanteDB jobs can be run on a schedule. The schedule for jobs are persisted (by default) in the `xcron.xml` file in the installation directory (this can be changed by registering or implementing `IJobScheduleManager`).

Scheduling a job is performed by clicking on the `Schedule` button on the job summary page.

![](https://3421852694-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LZ0_pjgTp_kx4hqTZ3a%2Fuploads%2FimVJ2qmoIIcc9XQP60dP%2Fimage.png?alt=media\&token=9011988a-9d4b-4321-b2aa-5dfe7088e1ef)

Upon opening the job schedule, a window will appear allowing the user to configure a job schedule. There are two methods for setting a job schedule:

### Interval Schedule

An interval schedule is used when the job should be run on a regular timed interval. This timer is started when the SanteDB host process is started and repeats at the specified timing.

![](https://3421852694-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LZ0_pjgTp_kx4hqTZ3a%2Fuploads%2FUCp5bYZ8WY8ipi4exKPh%2Fimage.png?alt=media\&token=79d52d02-3aa7-49c2-9353-12088dad6442)

### Calendar Schedule

A calendar schedule should be used whenever the job needs to be executed on a repeated calendar day. For example, to refresh the materialized views at 11 PM every day starting January 26, 2022.

![](https://3421852694-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LZ0_pjgTp_kx4hqTZ3a%2Fuploads%2FvPHsP307mzGsAw2tRaGZ%2Fimage.png?alt=media\&token=71b80810-02f5-4e66-a702-230b15d5dbb8)

If a future date or time is specified, then the job will only run&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://help.santesuite.org/operations/cdr-administration/santedb-administration-panel/system-administration/jobs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
