How to do a job in user defined date and time (like schedule a job)

Hello!
I want to do like schedule sending email.

  1. customer(user) set date and time for sending email.
  2. app sends email at given time.

is there any package in elixir?
or should I implement manually?

Thanks

I tend to use the Quantum library for such things.

2 Likes

or EctoJob - if you want/need persistence (which afaik quantum doesn’t provide) EctoJob: A transactional job queue built with Ecto, PostgreSQL and GenStage (or Rihanna https://github.com/samphilipd/rihanna that afaik works somewhat similarly)

there is also SchedEx https://github.com/SchedEx/SchedEx

I use quantum for fixed scheduled jobs (eg every hour) - and would probably go for EctoJob for on-demand scheduled jobs… ymmv obviously

2 Likes

Oh yes, I am using Quantum for cleaning up database something like that.
and and I configured in config.exs

config  :texting, Texting.Scheduler,
  jobs: [
    
    {"@daily", {Texting.Cronjob, :remove_orders, []}}
  ]

and it is global job.

does quantum work as individual scheduler also? if it does, can you give me a link to the doc? I am trying to find docs in https://hexdocs.pm/quantum/readme.html but it isn’t easy.

Thanks

https://hexdocs.pm/quantum/runtime.html

Though it won’t persist through reboots, for that you’d want EctoJob or so (or serialize it yourself, pretty trivial to do), but if it’s just a janitorial cleanup or something then it’s perfect. :slight_smile:

Thanks! I will look into that.

1 Like