Search code examples
timercronerlang

Cron implementation in Erlang


I need to provide a way to perform actions at specific date/time repeatedly. Basically it should work like Cron and I'm thinking of the way of managing execution times.

One solution could be to run a loop in each job/process and constantly check (every minute or second) whether current time is the time we are waiting for.

Another solution could be to work with timers by waiting until the next execution. We calculate the difference between now and the next execution time, and supply that delay to the timer. But since the execution times should be manageable, we would need to have a way to interrupt that timer and create a new one, or we could simply kill that process and create a fresh one.

Does anyone have any thoughts on how it should be done properly, or are they any libraries for accomplishing this particular scenario?


Solution

  • Here are 4 libs you could take a look at:

    https://github.com/erlware/erlcron

    https://github.com/b3rnie/crontab

    https://github.com/jeraymond/leader_cron

    https://github.com/zhongwencool/ecron