Moaz Mansour

View Original

Event Scheduling on Postgres.APP on Mac OS

Are you struggling to create scheduled event triggers in Postgres on your Mac OS? Unlike MySQL, Postgres doesn't come with this feature readily available. However, don't worry! You can add extensions to your Postgres database to do this for you. In this guide, we'll be using pg_cron, a simple cron-based job scheduler for PostgreSQL that runs inside the database as an extension.

In fact, If you're using Amazon RDS, you're in luck. Starting with PostgreSQL version 12.5 and higher, their RDS instances come natively supported with pg_cron to schedule event triggers. Check their announcement here. For activating pg_cron on an AWS PSQL, follow this tutorial.

Terminal Postgres

To use pg_cron with your terminal Postgres, you can install it by building it from the source as follows:

See this content in the original post

Postgres.APP

If you're using Postgres.APP to manage your local Postgres Database cluster, you can install pg_cron as an extension to your cluster as follows:

See this content in the original post

In conclusion, adding cron job scheduling to your PostgreSQL database can greatly simplify your workflow and automate routine tasks. By installing pg_cron, you can easily schedule jobs directly within your database without the need for external tools. Once you have followed the steps outlined in this article, you can start your database and use pg_cron to schedule jobs to run at specific times or intervals.

See this content in the original post

For examples on how to create cron jobs, be sure to check out the pg_cron GitHub page.