
RDS will take care of the scaling, backup, maintenance, patching, and failover for you so that you can focus on your application. On the relational side, you can use the Relational Database Service (RDS) to run a MySQL, Oracle, or SQL Server database. Hope this article helps you on your daily work and thank you for taking the time to follow me until here, and as always, if you have any questions please write them in the comments below 👇.You have a plethora of options when you want to run a relational or NoSQL databases on AWS. To stop/delete a job → SELECT cron.unschedule(job_id).To list the run details → SELECT jobid, username, status, return_message, start_time FROM cron.job_run_details.To list all cron jobs → SELECT * FROM cron.job.SELECT cron.schedule('5 * * * *', $$DELETE FROM events$$) Useful commands We could do a cron job that would do something like that. We want to delete all the events from the table every 5 minutes. That table will be populated with a lot of data pretty fast 💨. Imagine you have an events table, and that table is flooded with events every millisecond. If you reached this far, you can finally create cron jobs to help you execute those repetitive tasks. * Enable pg_cron extension */ĬREATE EXTENSION pg_cron Example job you can do with pg_cron For that, we should run the following command. We enabled it on the AWS Console, but now we need to tell our database to go get the extension. Working with cron on the database Enable pg_cron extensionįor you to test and work with cron jobs on your database, your first need to enable it. Now, I'll show you some commands you can do on your database with cron.
#Aws postgresql 12 how to

You can use the search bar on top of the parameters to help you find it!Īdd the value pg_cron to the shared_preload_libraries parameter. We need add pg_cron extension, so the way to add extensions is to create a parameter group which is a copy of the default parameter group and add the desired extension.Īccess your AWS RDS Console and enter on the Parameter Groups tab on the left panel.Ĭlick on Create parameter group and fill in the details about it.Īccess your parameter group and search for the shared_preload_libraries parameter. ⚠️ If you find yourself struggling with the configuration or you find any typos in the article, please comment below! Me & all the DevOps team at Coletiv will be more than happy to help you or fix what's wrong. Add pg_cron to your database on AWSįirstly, let's configure on our AWS Console the pg_cron extension to the database we want to use cron jobs. In our case, we needed to bulk delete a huge set of records, and cron jobs came in handy.īy default, cron jobs are disabled on PostgreSQL RDS instances, so to use them on our database we need to enable them on Amazon Web Services (AWS) RDS console.


A database cron job is a process for scheduling a procedure or command on your database to automate repetitive tasks.
