# CREATE JOB
source: https://docs.chalk.ai/docs/chalksql/jobs/create-job

## Create a suspended Chalk SQL job with a recurring schedule and an optional resource group.

CREATE JOB creates a SQL job in the SUSPENDED state. Use OR REPLACE to update
an existing SQL job. Use
ALTER JOB ... RESUME to start scheduled runs.

### Syntax

```sql
{ CREATE JOB [ IF NOT EXISTS ] | CREATE OR REPLACE JOB } <name>
  { SCHEDULE = '<schedule>' [ RESOURCE_GROUP = '<resource_group>' ]
  | RESOURCE_GROUP = '<resource_group>' SCHEDULE = '<schedule>' }
  AS <statement>;
```

### Required parameters

| Parameter | Description                                                                                               |
| --------- | --------------------------------------------------------------------------------------------------------- |
| ``        | A SQL identifier unique among the environment's SQL jobs and the scheduled jobs in its active deployment. |
| ``        | A Chalk duration such as `1m` or a five-field UTC cron expression such as `0 9 * * *`.                    |
| ``        | One Chalk SQL statement to run each time the job fires.                                                   |

### Optional parameters

| Parameter        | Description                                                                                                                                                                                                                                            |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `IF NOT EXISTS`  | Returns the existing SQL job with the same name. If the name is available, creates a suspended job.                                                                                                                                                    |
| `OR REPLACE`     | Lets the job creator update the statement, schedule, and resource group while preserving run history and the active or suspended state. If the name is available, creates a suspended job. Each run reads the job statement when it submits the query. |
| `RESOURCE_GROUP` | The [resource group](/docs/chalksql/sql-explorer#resource-groups) for async SQL execution. If omitted, the job uses the environment's default group.                                                                                                   |

### Return values

The command returns one row describing the resulting schedule with the columns of chalk.jobs.

### Permissions

Creating or replacing a SQL job requires query.online, cron.create, and workflow.manage
in the environment. Returning an existing SQL job with IF NOT EXISTS also requires workflow.read.

### Examples

Create a job scheduled for 09:00 UTC every day.

```sql
CREATE JOB morning_report
  SCHEDULE = '0 9 * * *'
  AS SELECT 42 AS answer;
```

Update the job to run at 10:00 UTC every day.

```sql
CREATE OR REPLACE JOB morning_report
  SCHEDULE = '0 10 * * *'
  AS SELECT 42 AS answer;
```

### See also

- Job statements for job names and related commands
- Scheduled SQL for creating, testing, and resuming a job in the dashboard




