Skip To Content
ArcGIS Developer
Dashboard

Create Task

Description

The createTask operation creates scheduled tasks for a deployment that run automatically. Once the task has been created, it can be updated using the update operation. In addition, scheduled tasks can be disabled, reenabled, and deleted using other operations in the ArcGIS Enterprise Administrator API.

Note:

Currently, this operation only supports scheduling CreateBackup tasks.

Request parameters

ParameterDetails
title

(Optional)

The title of the task.

Example

title=backups
type

(Required)

The task type. Currently, this must be set to CreateBackup.

Example

type=CreateBackup
parameters

(Required)

A JSON object of additional parameters that will be added to the task run request. For CreateBackup, parameters must include the following properties:

  • name—The prefix of the backup name, appended with the date the backup was created.
  • passcode—The value that will be used to encrypt the backup when it is created and decrypt the backup when it is restored. The passcode must be at least eight characters.
  • storeName—The backup store in which the backup will reside.
  • metaData—A JSON array that determines when the backup starts, if it is recurring, and the retention information to determine when it will be deleted. The following properties are required:
    • recurring—A Boolean value that determines whether the schedule creates a backup once or a recurring backup.
    • startTime—A string representation of the time the backup will be created in Greenwich mean time, using 24-hour notation.
    • retention—A JSON array of when the backup will be deleted, which includes a type property to specify the time units (day, week, or month) and the associated value for the unit.
  • retentionOffset—The milliseconds calculation of the retention value. This should match the information in the retention JSON array for the metaData property.

Example


//Create a backup at midnight, local time, with each backup getting deleted after 14 days
parameters={"name": "myBackup","passcode": "myPassword","storeName": "backups","metaData": {"recurring": false,"startTime": "04:00","retention": {"type": "day","value": 14}},"retentionOffset": 1209600000}
startDate

(Optional)

The date, defined in epoch milliseconds (Unix time), the task will begin running.

Example

startDate=1589428800000
endDate

(Optional)

The date, defined in epoch milliseconds (Unix time), the task will stop running.

Example

endDate=1589428800000
minute

(Required)

A valid CRON expression (, - * /) that specifies the minute value for the task's schedule. For sample schedules, see the CRON expressions section below.

Example

minute=0
hour

(Required)

A valid CRON expression (, - * /) that specifies the hour value for the backup task's schedule. For sample schedules, see the CRON expressions section below.

Example

hour=0
dayOfMonth

(Required)

A valid CRON expression (, - * ? / L W LW) that specifies the day of the month value for the backup task's schedule. For sample schedules, see the CRON expressions section below.

Example

dayOfMonth=?
month

(Required)

A valid CRON expression (, - * /) that specifies the month value for the task's schedule. For sample schedules, see the CRON expressions section below.

Example

month=*
dayOfWeek

(Required)

A valid CRON expression (, - * ? / L #) that specifies the day of the week value for the backup task's schedule. For sample schedules, see the CRON expressions section below.

Example

dayOfWeek=7
maxOccurrences

(Optional)

The maximum number of occurrences the task will execute.

Example

maxOccurrences=1
f

The response format. The default format is html.

Values: html | json | pjson

CRON expressions

Special characters and wildcards can be used to customize scheduled jobs. The following table lists the supported characters:

CharacterDetails
*

Specifies all values.

?

No specific value for dayOfMonth and dayOfWeek expressions.

-

A range.

,

A list of additional values.

/

Specifies increments.

#

The nth day name of the month (applies only to dayOfWeek).

L

The last day of the week or month.

W

The weekday (Monday-Friday) nearest the given day (applies only to dayOfMonth).

LW

The last weekday of the month.

The following table shows sample schedules and how they translate to CRON values for the minute, hour, dayOfMonth, month, and dayOfWeek parameters:

ScheduleminutehourdayOfMonthmonthdayOfWeek

Hourly at 15 minutes past the hour

15

*

*

*

?

Every four hours during weekdays

0

*/4

?

*

1-5

Weekly on Sundays at 12:00 p.m.

0

12

?

*

7

Twice a month on the 1st and 15th at 12:00 a.m.

0

0

1,15

*

?

Last Friday of every month at 10:00 p.m.

0

22

?

*

6L

Last day of the month at 10:00 p.m.

0

22

L

*

?

Last weekday of the month at 6:00 p.m.

0

18

LW

*

?

Closest weekday to the 15th of each month at midnight

0

0

15W

*

?

Example usage

The following is a sample POST request for the createTask operation that demonstrates scheduling a CreateBackup task that will run weekly on Sundays at 12:00 a.m.:


POST /context/admin/system/tasks/createTask HTTP/1.1
Host: organization.domain.com
Content-Type: application/x-www-form-urlencoded
Content-Length: []

title=backups&type=CreateBackup&parameters={"name": "myBackup","passcode": "myPassword","storeName": "backups","metaData": {"recurring": false,"startTime": "04:00","retention": {"type": "day","value": 14}},"retentionOffset": 1209600000}&startDate=1589428800000&endDate=1589428800000&minute=0&hour=0&dayOfMonth=?&month=*&dayOfWeek=7&maxOccurrences=1&f=pjson&token=HRozb6bnTL6gfA-SJO-IxhfLgJrioK1KJdMLWmCE5HjHWz9U3fOiFv3-HkgPZqsLljTkk2WDENGt5fjho5s39e_mZL5At60UvJPoNnC5O2sv2HTlumG7TsYfbtnokpWmS6-lf8XoQpSKusZwmxIkEMP-yE0Wxrj8o9sWKi29J-pxzkoCDhoUfdLt6NnBWxhESpegh8BzNcEruqxuDQD-JRmaTsbRDaBHTQTePMzQePhXl7KcEG9Cfkw2sa7P1W1e

JSON Response example


{
  "name": "schedule1",
  "passcode": "{crypt}3ngE7lQuQGDfaiab4uogjg==",
  "storeName": "default",
  "itemId": "",
  "metaData": {
    "recurring": true,
    "startTime":" 20:00",
    "retention": {
      "type": "day",
      "value": 14
    }
  },
  "retentionOffset": 1209600000
}