# Scheduled jobs (IRPCScheduledJobsAdmin)

Location: [gRPC API](https://developer.m-files.com/APIs/gRPC-API/index.md) > [Administration API](https://developer.m-files.com/APIs/gRPC-API/admin/index.md)

HTML version: https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/

Lists, adds, changes, removes, starts and cancels scheduled jobs of the server or of a vault.

Use this interface to add, remove and modify scheduled jobs.

- **gRPC service:** `MFiles.IRPCScheduledJobsAdmin`
- **Book and level:** [Administration API](https://developer.m-files.com/APIs/gRPC-API/admin/index.md), specialized
- **Methods:** 10
- **Proto file:** [`mfiles/IRPCScheduledJobsAdmin.proto`](https://developer.m-files.com/APIs/gRPC-API/downloads/proto/mfiles/IRPCScheduledJobsAdmin.proto)

<a id="overview"></a>

## Overview

M-Files Admin uses this service for scheduled jobs (backups, vault copies, verification) and for
the archiving and optimization jobs of a vault. A job is a
[ScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ScheduledJob/index.md): a `type`, the job details in `data`, an `is_enabled`
flag and a `schedule`. Its state is a
[ScheduledJobRunInfo](https://developer.m-files.com/APIs/gRPC-API/Reference/Messages/MFiles.ScheduledJobRunInfo/index.md): whether it is running, the last and
next run, errors and progress.

**Two job lists.** The session decides which jobs a call sees; their IDs are separate.

| Session | Jobs | Rights |
| --- | --- | --- |
| Server-level (`login_data.vault_guid` = null GUID) | Server jobs: backup, restore, copy vault, verify vault, recalculate property, migrate vault, encrypt file data, and optimize vault | Server right `manage_jobs` (system administrator server role) |
| Vault session | The vault's jobs: archive objects, archive old versions, restore from archive, optimize vault | Vault rights `archive` and `restore_from_archive`, or `manage_scheduled_jobs`; optimize vault jobs need `manage_scheduled_jobs` |

A server job cannot be handled in a vault session, and archiving jobs only in a session of their
vault. A vault administrator therefore manages the vault's archiving and optimization jobs but
not backups. Exceptions for server jobs: reading, starting and cancelling recalculate property
jobs, and reading verify vault jobs, do not need `manage_jobs`. Archiving jobs also need a
license that includes archiving. Missing rights fail with "Access denied.".

Typical calls: [GetScheduledJobs](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/GetScheduledJobs/index.md) to list,
[AddScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/AddScheduledJob/index.md) /
[ModifyScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/ModifyScheduledJob/index.md) /
[RemoveScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/RemoveScheduledJob/index.md) to maintain,
[StartScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/StartScheduledJob/index.md) to run one now, then
poll [GetScheduledJobRunInfo](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/GetScheduledJobRunInfo/index.md)
until `is_running` is false.

**Unset times.** In run info, "never" or "no next run" is the timestamp 1601-01-01T00:00:00Z,
not an unset field.

<a id="methods"></a>

## Methods

| Method | Summary | Facts |
|---|---|---|
| [AddScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/AddScheduledJob/index.md) | Adds a scheduled job to the server or to the vault, depending on the job type. | `admin` `session` |
| [CancelScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/CancelScheduledJob/index.md) | Asks a running scheduled job to stop. | `admin` `session` `idempotent` |
| [DownloadScheduledJobOutputFile_ReadBlock](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/DownloadScheduledJobOutputFile_ReadBlock/index.md) | Reads a block of a job output file, such as the summary of a restore from archive preview. | `admin` `session` `idempotent` |
| [GetScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/GetScheduledJob/index.md) | Gets one scheduled job and its run state. | `admin` `session` `idempotent` |
| [GetScheduledJobRunInfo](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/GetScheduledJobRunInfo/index.md) | Gets the run state of a scheduled job: running or not, last and next run, errors and progress. | `admin` `session` `idempotent` |
| [GetScheduledJobs](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/GetScheduledJobs/index.md) | Gets the scheduled jobs of the server (server-level session) or of the vault (vault session), with their run state. | `admin` `session` `idempotent` |
| [ModifyScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/ModifyScheduledJob/index.md) | Replaces the definition of an existing scheduled job. | `admin` `session` `idempotent` |
| [RemoveScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/RemoveScheduledJob/index.md) | Removes a scheduled job. | `admin` `session` |
| [ResetScheduledJobProgress](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/ResetScheduledJobProgress/index.md) | Resets the saved progress of an optimize vault job, so that its next run retries the failed step or starts over. | `admin` `session` `idempotent` |
| [StartScheduledJob](https://developer.m-files.com/APIs/gRPC-API/Reference/MFiles.IRPCScheduledJobsAdmin/StartScheduledJob/index.md) | Runs a scheduled job now, outside its schedule. | `admin` `session` `idempotent` |
