Periodic Scheduler

Context

It’s a fundamental requirement that we need to run a command at a specific time.

Overview

Periodical Scheduler schedules code to be executed periodically. It has below features:

Solutions

Crontab

Crontab is a Unix utility that gets installed in almost every Unix / Linux distribution.

Check the manual of crontab.

Kubernetes CronJob

Kubernetes Cron Job is like crontab file in my forms except that it runs in a Kubernetes cluster.

Check the documentation of Running Automated Tasks with a CronJob.

Scheduler Libraries

Scheduler libraries let you schedule code to be executed later. Below are some typical implementations:

The libraries are useful when you want to integrate scheduler into your application.

Patterns

Conclusions

Using crontab is the easiest way to schedule periodic jobs. The limitation is that you can’t control the resource usage and it’s less flexible. To run periodic jobs in a fine-controlled environment, you might want to choose Kubernetes CronJob. To leverage the power of periodic scheduler, you might want to integrate a scheduler library into your application.