Skip to content

Commit a2af446

Browse files
authored
Update 01-ddl-create_task.md
1 parent b4ddb01 commit a2af446

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

docs/en/sql-reference/10-sql-commands/00-ddl/04-task/01-ddl-create_task.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,48 @@ AS
5858
- Tasks will not retry on each execution; each execution is serial. Each script SQL is executed one by one, with no parallel execution. This ensures that the sequence and dependencies of task execution are maintained.
5959
- Interval-based tasks follow a fixed interval spot in a tight way. This means that if the current task execution time exceeds the interval unit, the next task will execute immediately. Otherwise, the next task will wait until the next interval unit is triggered. For example, if a task is defined with a 1-second interval and one task execution takes 1.5 seconds, the next task will execute immediately. If one task execution takes 0.5 seconds, the next task will wait until the next 1-second interval tick starts.
6060

61+
### Important Notes on Cron Expressions
62+
63+
- The cron expression used in the `SCHEDULE` parameter must contain **exactly 6 fields**.
64+
- The fields represent the following:
65+
1. **Second** (0-59)
66+
2. **Minute** (0-59)
67+
3. **Hour** (0-23)
68+
4. **Day of the Month** (1-31)
69+
5. **Month** (1-12 or JAN-DEC)
70+
6. **Day of the Week** (0-6, where 0 is Sunday, or SUN-SAT)
71+
72+
#### Example Cron Expressions:
73+
74+
- **Daily at 9:00:00 AM Pacific Time:**
75+
- `USING CRON '0 0 9 * * *' 'America/Los_Angeles'`
76+
77+
- **Every minute:**
78+
- `USING CRON '0 * * * * *' 'UTC'`
79+
- This runs the task every minute at the start of the minute.
80+
81+
- **Every hour at the 15th minute:**
82+
- `USING CRON '0 15 * * * *' 'UTC'`
83+
- This runs the task every hour at 15 minutes past the hour.
84+
85+
- **Every Monday at 12:00:00 PM:**
86+
- `USING CRON '0 0 12 * * 1' 'UTC'`
87+
- This runs the task every Monday at noon.
88+
89+
- **On the first day of every month at midnight:**
90+
- `USING CRON '0 0 0 1 * *' 'UTC'`
91+
- This runs the task at midnight on the first day of every month.
92+
93+
- **Every weekday at 8:30:00 AM:**
94+
- `USING CRON '0 30 8 * * 1-5' 'UTC'`
95+
- This runs the task every weekday (Monday to Friday) at 8:30 AM.
96+
6197
## Usage Examples
6298

6399
```sql
64100
CREATE TASK my_daily_task
65101
WAREHOUSE = 'compute_wh'
66-
SCHEDULE = USING CRON '0 9 * * * *' 'America/Los_Angeles'
102+
SCHEDULE = USING CRON '0 0 9 * * *' 'America/Los_Angeles'
67103
COMMENT = 'Daily summary task'
68104
AS
69105
INSERT INTO summary_table SELECT * FROM source_table;
@@ -105,7 +141,7 @@ In this example, a task named process_orders is created, and it is defined to ru
105141
```sql
106142
CREATE TASK IF NOT EXISTS hourly_data_cleanup
107143
WAREHOUSE = 'maintenance'
108-
SCHEDULE = '0 * * * *'
144+
SCHEDULE = '0 0 * * * *'
109145
WHEN STREAM_STATUS('change_stream') = TRUE
110146
AS
111147
DELETE FROM archived_data

0 commit comments

Comments
 (0)