Recurring scheduled tasks (like cron)

I won’t judge if someone uses “local” checks to accomplish this.

With [[services]]: Healthchecks and private networks - #2 by kurt

Without [[services]]: Non-service health checks - #3 by jerome


The ambitious amongst us might want to experiment with Cloudflare’s Scheduled Durable Objects with Fly Machines FaaS.

The only reason I’d ask for this is knowing that underlying orchestrator (Nomad) has built-in cron.

Meanwhile, I’m just using image with crond -f -d 0 cmd. Works just fine :ok_hand:

1 Like

We just released scheduled machines :tada: Any and all feedback appreciated → New feature: Scheduled machines

2 Likes

Running yacron as a secondary process (with this caveat in mind) has been working well for me.

1 Like

I wrote a guide for running superchronic in a Fly container at Crontab with Supercronic · Fly Docs, which is a drop-in replacement for cron. If you need specificity beyond Fly’s Scheduled Machines feature you’ll want to go down this path since Fly doesn’t have any immediate plans of full-blown cron for scheduling Machines.

2 Likes

Hi Brad,

I tried to follow the above guide but I get the following error:

Error not enough volumes named app_name_data (1) to run 2 processes

I have the following in my fly.toml file:

`[mounts]
  source="app_name_data"
  destination="/data"
[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["web"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"
[processes]
  # The command below is used to launch a Rails server; be sure to
  # replace with the command you're using to launch your server.
  web = "bin/rails fly:server"
  cron = "supercronic /app/crontab"`

I tried autoscaling, but this didn’t work. Any idea why this might be?

Just for reference for anyone using NodeJS I opted for BullMQ which supports repeatable jobs and a lot more like automatic retries etc and because it’s Redis backed (I’m using Upstash for now) you can add as many worker instances as you need, currently I have them a part of my web-app but later might separate as needed :nerd_face:

1 Like

Another reference, just stumbled upon KEYDB.CRON: schedule Lua scripts with your database | KeyDB - The Faster Redis Alternative, not sure I’m going to use it myself, but I started using KeyDB and thought might be nice to mention this possibility here for anyone using or considering KeyDB :wink:

1 Like