cheek: a KISS job scheduler
Published: 2022-01-18 10:00:16

---
title: cheek: a KISS job scheduler
published: true
date: 2022-01-18 01:00:00 UTC
tags: 
canonical_url: https://dataroots.io/research/contributions/cheek:-a-kiss-job-scheduler
---

<sub><b>author(s):</b> Bart Smeets</sub>

Soo... I got asked by [Virginie Marelli](https://www.linkedin.com/in/virginie-marelli-58721970/) to explain what `cheek` is. Here goes:

`cheek` is an approach at building a simple job scheduler that just works for the simple stuff. If you would look at [Airflow](https://airflow.apache.org/) as `crontab` on steroids, you can look at `cheek` as `crontab` with a bit of sugar sprinkled on top.

The original name of this small side project was **B** etter **U** nified **T** ime-driven **T** asks. Such a self exploratory name would have removed the need for any explanation on what the package does. However, it was hard to create an acronym from that name which would withstand the test of [time](https://github.com/datarootsio/cheek/commit/f264623a57acb340e29c5d4af77d5a96febfaa39).

But, silliness aside, when would you use this?

- You want an easy to containerize, self-contained job scheduler.
- Robustness is secondary to ease of implementation & use.
- You want to actively be notified if sh&t hits the fan.
- You want to configure your jobs through a simple YAML.
- Tasks should respect your timezone.
- You just wanna look cool by using `cheek`'s TUI.

So how to use it? First and foremost, when in doubt, you can always fall back on [RTFM](https://github.com/datarootsio/cheek/) mode.

Given the [README](https://github.com/datarootsio/cheek/) is pretty much self-explanatory I'll focus here on how to define a task schedule. You basically configure `cheek` through a yaml that defines the specs of your task schedule. At its most basic it looks as follows:

<deckgo-highlight-code language="yaml" terminal="carbon" theme="vscode">
          <code slot="code">jobs:
    foo:
        command: echo bar</code>
        </deckgo-highlight-code>

This config defines a job called `foo` that will execute the command `echo bar` when triggered. However, it does not define a cron string. So the only way to trigger this job is to trigger it manually. You can do so as follows:

<deckgo-highlight-code terminal="carbon" theme="vscode">
          <code slot="code">cheek trigger my_schedule.yaml foo

6:03PM INF Job triggered job=foo trigger=manual
bar</code>
        </deckgo-highlight-code>

To schedule this job to run at specific interval we use cron strings. Check out [crontab guru](https://crontab.guru/) for a bit of cron definition support. We can define the `foo` job to run every day at [8AM](https://crontab.guru/#0_8_*_*_*) as follows. We can also add the timezone that we prefer, to make sure that 8AM is our 8AM regardless of where in the world your job runs.

<deckgo-highlight-code terminal="carbon" theme="vscode">
          <code slot="code">tz_location: Europe/Brussels
jobs:
  foo:
    command: echo bar
	cron: 0 8 * * *</code>
        </deckgo-highlight-code>

You can start this schedule by running below command. This will start the cheek process that will run indefinitely.

<deckgo-highlight-code terminal="carbon" theme="vscode">
          <code slot="code">cheek run my_schedule.yaml</code>
        </deckgo-highlight-code>

Check out the example [Dockerfile](https://github.com/datarootsio/cheek/blob/main/Dockerfile) if you want to know how you can set this up in a container.

Let's look at some extra sugar you can sprinkle on top of your tasks:

<deckgo-highlight-code terminal="carbon" theme="vscode">
          <code slot="code">tz_location: Europe/Brussels
jobs:
  foo:
    command: echo bar
	cron: 0 8 * * *
	on_success:
      trigger_job:
	    - rick
  ricky:
    command: echo roll
  failing_job:
    command: this_command_fails
	cron: 0 9 * * *
	on_error:
	  notify_webhook:
	    - https://my_webhook_url/</code>
        </deckgo-highlight-code>
- `on_success` and `on_error` allow you to define actions that need to occur after one of the post job run events
- `trigger_job` allows you trigger a job to be run
- `notify_webhook` will send the result of your job run to a web hook
- `on_success` and `on_error` can be specified on a global level

Cool thing about these web hooks is that you can easily hook them up to something like Slack. This allows you to specify certain jobs about which you want to receive active notifications. If you wanna go this route, make sure to check out [Webhook.site](https://webhook.site/) for testing the output and something like [Zapier](https://zapier.com) for hooking this up to things like Slack.

Ow yes, there is also a TUI, made possible by the fine folks over at [Charm](https://charm.sh/). I mean, that's just cool, right?

![image 1 1](https://dataroots.io/static/f8aa3360f0394c543a3da916da26bdf4/fcda8/image-1-1.png "image 1 1")

What we do with this at [Dataroots](https://dataroots.io) you might wonder? We have an actively evolving set tools, bots, platforms and data storages that we use for our day to day operations. `cheek` basically runs a bunch of tasks to keep stuff in sync and, arguably more important, people happy.

Why use `cheek` for this you might wonder? The official reason is that I was frustrated by the huge gap between simplistic crontab installations and the (very) robust Airflow/Flyte/Prefect setups. `cheek` tries to fill a gap between these types of solutions. The unofficial answer is that I wanted a cool side project and that I needed a job scheduler for our internal tooling, that made me think of a good official reason for doing this.

All information you actually need about cheek you can find in its [repository](https://github.com/datarootsio/cheek).