S
Supabase9mo ago
Genio

Cron job in job table but not executing

I created a new cron job using the tutorial and edited the end point to have my edge function and it seems that the edge function is not executing. I tried pg_net alone and testing and i received the invocation but when i tried to do it via pg_cron it seems the job is not even executing i followed the soloution here https://github.com/orgs/supabase/discussions/1628#discussioncomment-977498 but it still doesnt execute. Let me know if you need anymore details since i am not sure what would be helpful to provide! Thank you for your work
GitHub
pg_cron / seems job never executed · supabase · Discussion #1628
I tried to execute a simples CRON job with pg_cron by following the official tutorial https://supabase.io/blog/2021/03/05/postgres-as-a-cron-server and it's not working for me. Where I'm no...
12 Replies
garyaustin
garyaustin9mo ago
You should show your cron code/function. Are you using the Cron UI?
Genio
GenioOP9mo ago
select
cron.schedule(
'resend-failed-messeges',
'55 */12 * * *', -- it was 00:50 and when it become 00:56 it didnt run
$$
select
net.http_post(
url:='https://deletedForSaftey.com',
headers:='{"Content-Type": "application/json", "Authorization": "Bearer eyJhbG2ibIKaCS1EPdmOZbhQ8BXRvnPGFWIgnNTix8sM30...","GenSign":"no"}'::jsonb
-- body:=concat('{"time": "', now(), '"}')::jsonb
) as request_id;
$$
);
select
cron.schedule(
'resend-failed-messeges',
'55 */12 * * *', -- it was 00:50 and when it become 00:56 it didnt run
$$
select
net.http_post(
url:='https://deletedForSaftey.com',
headers:='{"Content-Type": "application/json", "Authorization": "Bearer eyJhbG2ibIKaCS1EPdmOZbhQ8BXRvnPGFWIgnNTix8sM30...","GenSign":"no"}'::jsonb
-- body:=concat('{"time": "', now(), '"}')::jsonb
) as request_id;
$$
);
Done, what is the cron UI? Also, i tried at 00:35 and 00:45 and kept deleteing the job and trying again still didnt send
garyaustin
garyaustin9mo ago
Also check the Postgres logs in the dashboard for errors.
No description
Genio
GenioOP9mo ago
Oh thank you, i remember seeing a ui but dont remember where
No description
Genio
GenioOP9mo ago
No errors in postgres logs
Genio
GenioOP9mo ago
No description
garyaustin
garyaustin9mo ago
Does your cron job show up in the cron.job_run_details table or the cron.job table?
Genio
GenioOP9mo ago
Only cron.job
garyaustin
garyaustin9mo ago
I'm not going to try and guess you time format for cron, but maybe that is wrong? See if the UI comes up with the same time format.
Genio
GenioOP9mo ago
It does, as you see here it says every 12 hours Its gmt+3 And shows the same on supabase Would it be possible that the cron job is running on a different time zone?
garyaustin
garyaustin9mo ago
It should run on gmt which is the Supabase default for their servers.
Genio
GenioOP9mo ago
Hmm, then i'll remove the cronjob and reset it to make it run every 5 mins and test Update, every 5 mins works. It seems that its an issue with the timing. I will test it to 12 hours and see when the email comes. Thank you

Did you find this page helpful?