3 ms·
apples and oranges? pg_cron is for pg specific cron tasks. You use pg_cron to truncate a table, compute pg views, values, aggregates, etc. Basically just runni
by eddythompson80 1y ago
apples and oranges?
pg_cron is for pg specific cron tasks. You use pg_cron to truncate a table, compute pg views, values, aggregates, etc. Basically just running PG queries on a CRON schedule.
pg_cron itself won't run an external script for you. Like you can't do
SELECT cron.schedule('0/30 * * * *', $$ ./sendEmails.sh $$);
you can use pg_cron to insert a job-row in a jobs table that you have some consumer that runs a `select * from jobs where status = 'pending' limit 1;`. Then you're on the hook to handle the pg updates for dispatching and handling updates, job status, etc. You could even call that implementation pg-boss if it's not taken.
- hoppp 1y agoThere is an HTTP extension for postgres, so it can trigger external serverless functions via http request
- cpursley 1y agoWhat’s the name of that?
- hoppp 1y agohttps://github.com/pramsey/pgsql-http https://github.com/pramsey/pgsql-http It works well with Supabase, I tried it, its decent but you should only use it for endpoints you trust because waiting for the request is blocking. If you want the requests to be async you need to use pg_background extension with it
- hyperman1 1y agoThe postgres COPY FROM PROGRAM will run external scripts, as the postgres user. Not necessarily a good architecture, of course. I did one day manage to fix a broken sshd with it by passing it su commands (rate that experience as 0 stars, would not recommend)