What's the best way to run pg_cron on a database other than defaultdb?

Posted July 22, 2020 2k views
PostgreSQLDigitalOcean Managed PostgreSQL Database

Since pgcron is now supported in PostgreSQL 12 managed db, what would be the best way to use it if we have a database that is not defaultdb? Currently you can only install the pgcron extension into defaultdb. Since pgcron uses libpq, you can also run periodic jobs on other databases or other machines but you have to be a superuser so that is ruled out. Foreign Data Wrappers are the only other option I can see, but that seems like an unnecessary complication. I’d like to be able to just install the extension into my database but this requires modifying postgresql.conf to add cron.databasename.

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

Hi there,

Thank you for reaching out to DigitalOcean Support.

I understand you are able to install the pg_cron extension in the defaultdb database but when trying to install the extension in another database returns error.

Unfortunately that’s currently not something that is user configurable as pgcron only supports one database at a time and the only DB we’re sure to exist at creation time is the default one. (

If you have any additional questions, please let us know.

DigitalOcean Support

  • Can you at least grant “doadmin” user to change cron.job table in database defaultdb? That way we can manually update the database field.