Suppose if I run the following cron job in my DB:
SELECT cron.schedule('30 3 * * 6', $$DELETE FROM events WHERE event_time < now() - interval '1 week'$$);
will that ever stop running ? How can I delete it if I do not want the job to run anymore ?
If there is no other way I can stop the above job, Please suggest an alternative that I can use.
Thanks in advance!
You can find the job ID in the cron.job table and use the cron.unschedule function to stop the job:
postgres=# SELECT * FROM cron.job;
jobid │ schedule │ command │ nodename │ nodeport │ database │ username │ active │ jobname
───────┼────────────┼─────────────────────────────────────────────────────────────────┼───────────┼──────────┼──────────┼──────────┼────────┼─────────
1 │ 30 3 * * 6 │ DELETE FROM events WHERE event_time < now() - interval '1 week' │ localhost │ 5432 │ postgres │ marco │ t │
(1 row)
postgres=# SELECT cron.unschedule(1);
unschedule
────────────
t
(1 row)
postgres=# SELECT * FROM cron.job;
jobid │ schedule │ command │ nodename │ nodeport │ database │ username │ active │ jobname
───────┼──────────┼─────────┼──────────┼──────────┼──────────┼──────────┼────────┼─────────
(0 rows)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With