Skip to content

Commit fa72aba

Browse files
fix(rdb): cron pt 4
1 parent 86fbb41 commit fa72aba

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

pages/managed-databases-for-postgresql-and-mysql/api-cli/using-pgcron.mdx

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -144,35 +144,31 @@ SELECT cron.unschedule('nightly-vacuum');
144144

145145
## Scheduling jobs in other databases
146146

147-
To schedule a job in another database, you can use the `schedule_in_database` function:
147+
To schedule a job in another database, you can use the `schedule_in_database` function.
148148

149-
```sql
150-
SELECT cron.unschedule('${JOB_ID}');
151-
```
149+
In the example below we create a job to insert values into another table.
152150

153151
```sql
154152
SELECT cron.schedule_in_database('job-in-another-db', '0 12 * * *', 'INSERT INTO public.another_db_table values (now())', 'mydb');
155-
schedule
156-
----------
157-
3
158153
```
154+
<Message type="note">
155+
The `cron.schedule_in_database` function runs jobs as the user who created them. Therefore, you need to connect as said user to execute the job. This function does not allow specifying a different user, as it would require superuser privileges.
156+
</Message>
159157

160-
Note that cron.schedule_in_database runs jobs as the user who created them, so you'll need to connect as that user to execute the job.
161-
Additionally, this function doesn't allow specifying a different user, as it would require superuser privileges.
162158

163-
**Editing Jobs**
159+
## Editing Jobs
164160

165-
To edit a job, you can use the `alter_job` function:
161+
To edit a job, you can use the `alter_job` function.
162+
163+
In the example below
166164

167165
```sql
168166
SELECT cron.alter_job(job_id:=3,database:='anotherdb');
169-
-[ RECORD 1 ]
170-
alter_job |
171167
```
172168

173-
**Cron Syntax**
169+
## Cron specifications
174170

175-
The schedule uses the standard cron syntax:
171+
Schedules in `pgcron` use the standard Cron syntax:
176172

177173
```
178174
┌───────────── min (0 - 59)
@@ -186,6 +182,20 @@ The schedule uses the standard cron syntax:
186182
* * * * *
187183
```
188184

189-
**Time Zone**
185+
<Message type="tip">
186+
Refer to the [Cron schedules reference](/serverless-jobs/reference-content/cron-schedules/) for a detailed explanation of the cron format and examples.
187+
</Message>
188+
189+
### How to configure your schedule timezone
190+
191+
The time zone of the `pg_cron` extension can be changed in the advanced settings of the Database Instance. By default, the time zone is set to GMT.
190192

191-
The time zone of the pg_cron extension can be changed in the advanced settings of the instance: `cron.timezone`. By default, the time zone is set to GMT.
193+
1. Go to the **Advanced settings** of your Database Instance in the Scaleway console.
194+
2. Click <Icon name="edit" />.
195+
3. Click **+ Add parameters**.
196+
4. Select `cron.timezone` in the drop-down.
197+
5. Enter the time zone of your choice.
198+
6. Click <Icon name="validate" /> to validate.
199+
<Message type="note">
200+
The configuration takes a few seconds to be applied. During this time the Database Instance connection remains uninterrupted. However, you must wait until the new configuration is applied to edit your advanced settings again.
201+
</Message>

0 commit comments

Comments
 (0)