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

Since pg_cron 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 pg_cron extension into defaultdb. Since pg_cron 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.database_name.


Submit an answer
You can type!ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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 pg_cron 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.

Regards DigitalOcean Support