Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extensions-docs-327-pgcron initial #6231

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion advocacy_docs/pg_extensions/extensionrefs.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
"mongo_fdw": "https://github.com/Percona-Lab/mongodb_fdw",
"mysql_fdw": "https://github.com/EnterpriseDB/mysql_fdw",
"bdr_5.x":"https://www.enterprisedb.com/docs/pgd/latest/",
"pg_cron":"https://github.com/citusdata/pg_cron",
"pg_cron":"https://www.enterprisedb.com/docs/pg_extensions/pg_cron/",
"sql_profiler":"https://www.enterprisedb.com/docs/pem/latest/profiling_workloads/using_sql_profiler/",
"pg_squeeze":"https://www.enterprisedb.com/docs/pg_extensions/pg_squeeze/",
"wal2json":"https://www.enterprisedb.com/docs/pg_extensions/wal2json/",
Expand Down
2 changes: 1 addition & 1 deletion advocacy_docs/pg_extensions/index.mdx

Large diffs are not rendered by default.

37 changes: 37 additions & 0 deletions advocacy_docs/pg_extensions/pg_cron/configuring.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: Configuring pg_cron
navTitle: Configuring
---

1. In `postgresql.conf`, add `pg_cron` to the `shared_preload_libraries` parameter:

```ini
shared_preload_libraries = 'pg_cron'
```

If `shared_preload_libraries` has other extensions, then you can add `pg_cron` to the list. The order doesn't matter.


1. Metadata tables for `pg_cron` will be created in the "postgres" database, but you can alter this with:
```ini
cron.database_name = 'mydbname'
```

1. You can alter the timezone of pg_cron from GMT if required:
```ini
cron.timezone = 'PRC'
```

1. Restart Postgres.


1. Create the `pg_cron` extension in your database:

```shell
CREATE EXTENSION pg_cron;
```

1. Grant usage to `pg_cron` as needed to allow other users to schedule and manage their own jobs:
```ini
GRANT USAGE ON SCHEMA cron TO username;
```
23 changes: 23 additions & 0 deletions advocacy_docs/pg_extensions/pg_cron/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
title: 'pg_cron'
indexCards: none
navigation:
- rel_notes
- installing
- configuring
- using
directoryDefaults:
product: pg_cron
---

`pg_cron` is an extension released as open source software under the PostgreSQL License.

`pg_cron` is a cron-based job scheduler for PostgreSQL. You can schedule PostgreSQL commands directly from the database using a cron-based syntax.

For more information about `pg_cron`, see:

- [Installing pg_cron](installing.mdx)
- [Configuring pg_cron](configuring.mdx)
- [Using pg_cron](using.mdx)


71 changes: 71 additions & 0 deletions advocacy_docs/pg_extensions/pg_cron/installing.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
---
title: Installing pg_cron
navTitle: Installing
---

`pg_cron` is supported on the same platforms as the Postgres distribution you're using. Support for `pg_cron` starts with Postgres 10. For details, see:

- [EDB Postgres Advanced Server Product Compatibility](https://www.enterprisedb.com/platform-compatibility#epas)
- [PostgreSQL Product Compatibility](https://www.enterprisedb.com/resources/platform-compatibility#pg)
- [EDB Postgres Extended Server Product Compatibility](https://www.enterprisedb.com/resources/platform-compatibility#epas_extended)

## Installation

Before you begin the installation process:

- Install Postgres. See:

- [Installing EDB Postgres Advanced Server](/epas/latest/installing/)

- [Installing PostgreSQL](https://www.postgresql.org/download/)

- [Installing EDB Postgres Extended Server](/pge/latest/installing/)

- Set up the repository.

Setting up the repository is a one-time task. If you've already set up your repository, you don't need to perform this step.

To set up the repository, go to [EDB repositories](https://www.enterprisedb.com/repos-downloads) and follow the instructions provided there.

## Install the package

The syntax for the package install command is:

```shell
# For SLES, CentOS, RHEL and its derivatives
sudo <package-manager> -y install edb-<postgres><postgres_version>-pg-cron1

# For Debian and Ubuntu
sudo <package-manager> -y install edb-<postgres><postgres_version>-pg-cron-1
```

Where:
- `<package-manager>`is the package manager used with your operating system:

| Package manager | Operating system |
| --------------- | -------------------------------- |
| dnf | RHEL 8/9 and derivatives |
| yum | RHEL 7 and derivatives, CentOS 7 |
| zypper | SLES |
| apt-get | Debian and derivatives |

- `<postgres>` is the distribution of Postgres you're using:

| Postgres distribution | Value |
| ---------------------------- | ---------- |
| PostgreSQL | pg |
| EDB Postgres Advanced Server | as |
| EDB Postgres Extended Server | postgresextended |

- `<postgres_version>` is the version of Postgres you're using.

For example, to install pg_cron for EDB Postgres Advanced Server 15 on a RHEL 8 platform:

```shell
sudo dnf -y install edb-as15-pg-cron1
```





10 changes: 10 additions & 0 deletions advocacy_docs/pg_extensions/pg_cron/rel_notes/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
title: 'pg_cron release notes'
navTitle: "Release notes"
indexCards: none
---
The pg_cron documentation describes the latest version of pg_cron, including minor releases and patches. These release notes cover what was new in each release. For new functionality introduced in a minor or patch release, there are also indicators in the content about the release that introduced the feature.

| Version | Release Date |
| ----------------------------------- | ------------ |
| [1.6.4](pg_cron_1.6.4_rel_notes) | 09 Aug 2024 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Release notes for pg_cron version 1.6.4
navTitle: "Version 1.6.4"
---

For `pg_cron` release notes, see the [pg_cron official release notes](https://github.com/citusdata/pg_cron/releases/).
22 changes: 22 additions & 0 deletions advocacy_docs/pg_extensions/pg_cron/using.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
title: Using pg_cron
navTitle: Using
---

Use `pg_cron` to schedule various database maintenance and management tasks.

## Viewing the job status
```shell
select * from cron.job_run_details order by start_time desc limit 10;
```


## Purging the `cron.job_run_details` table
```shell
SELECT cron.schedule('0 0 * * *', $$DELETE
FROM cron.job_run_details
WHERE end_time < now() - interval '14 days'$$);
```


For more information on using `pg_cron`, see the [pg_cron documentation](https://github.com/citusdata/pg_cron).
Loading