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

How to execute cron in database other than postgres #361

Open
bhanotjyoti opened this issue Oct 29, 2024 · 1 comment
Open

How to execute cron in database other than postgres #361

bhanotjyoti opened this issue Oct 29, 2024 · 1 comment

Comments

@bhanotjyoti
Copy link

I am trying to execute

psql -d postgres -U postgres

SELECT cron.schedule_in_database('latest_height_job', '*/1 * * * *', 'my_db', 'my_user', $$ SELECT height FROM transactions ORDER BY height DESC LIMIT 1 $$);

It gives me error

pg_Cron is installed in postgres. How to schedule a cron in my_db

@TheOtherBrian1
Copy link

TheOtherBrian1 commented Nov 1, 2024

You can view the cron settings by running:

SELECT * FROM pg_settings where name ilike '%cron%';

pg_cron can only run within one database in your cluster. You can change the default by running:

ALTER SYSTEM SET cron.database_name = '<database>';

Because it's a postmaster level setting, you'll have restart the cluster (pg_ctl)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants