Supercronic job suddenly not working

Supercronic job setup that previously was working fine suddenly stopped working. This is my setup.

Dockerfile:

# syntax = docker/dockerfile:1

# Adjust BUN_VERSION as desired
ARG BUN_VERSION=1.1.40-slim
FROM oven/bun:${BUN_VERSION} as base

LABEL fly_launch_runtime="Bun"

# Bun app lives here
WORKDIR /app

# Install curl
RUN apt-get update -qq && \
    apt-get install --no-install-recommends -y ca-certificates curl gnupg && \
    rm -rf /var/lib/apt/lists /var/cache/apt/archives

# Latest releases available at https://github.com/aptible/supercronic/releases
ENV SUPERCRONIC_URL=https://github.com/aptible/supercronic/releases/download/v0.2.29/supercronic-linux-amd64 \
SUPERCRONIC=supercronic-linux-amd64 \
SUPERCRONIC_SHA1SUM=cd48d45c4b10f3f0bfdd3a57d054cd05ac96812b

RUN curl -fsSLO "$SUPERCRONIC_URL" \
&& echo "${SUPERCRONIC_SHA1SUM}  ${SUPERCRONIC}" | sha1sum -c - \
&& chmod +x "$SUPERCRONIC" \
&& mv "$SUPERCRONIC" "/usr/local/bin/${SUPERCRONIC}" \
&& ln -s "/usr/local/bin/${SUPERCRONIC}" /usr/local/bin/supercronic

# Copy the crontab file
COPY crontab /app/crontab

# Install npm modules
COPY --link bun.lockb package.json ./
RUN bun install --production --frozen-lockfile

# Create a non-root user to run the app
RUN useradd chrome --create-home --shell /bin/bash && \
    chmod -R +r /app/node_modules
USER chrome:chrome

# Copy application code
COPY --link . .

# Start the server
# CMD [ "bun", "run", "start" ]

# Run the app and the cron process
CMD ["sh", "-c", "bun run start & supercronic /app/crontab"]

fly.toml:

app = 'workhours-scrapper'
primary_region = 'otp'
swap_size_mb = 2048

[build]

[env]
  FORMAT = 'letter'
  JAVASCRIPT = 'false'
  TIMEOUT = '15'

[http_service]
  internal_port = 3000
  force_https = false
  auto_stop_machines = false
  auto_start_machines = true
  min_machines_running = 0
  processes = ['app']

  [http_service.concurrency]
    type = 'requests'
    hard_limit = 5
    soft_limit = 3

[[vm]]
  cpu_kind = 'shared'
  cpus = 1
  memory_mb = 1024

[processes]
  app = "bun run start"
  cron = "supercronic /app/crontab"

Crontab file:

00 22 * * * curl http://my-app.flycast/api/scrape

Any ideas what could be the reason that cron job is not triggered anymore?

Shell into the app, grab the Supercronic logs please, and post them here.

How many machines do you have in this app?

When I run supercronic -debug crontab I get:

INFO[2025-03-10T13:32:14Z] read crontab: crontab
DEBU[2025-03-10T13:32:14Z] try parse (6 fields): '00 22 * * * curl'
DEBU[2025-03-10T13:32:14Z] failed to parse (6 fields): '00 22 * * * curl': failed: syntax error in year field: 'curl'
DEBU[2025-03-10T13:32:14Z] try parse (5 fields): '00 22 * * *'
DEBU[2025-03-10T13:32:14Z] job will run next at 2025-03-10 22:00:00 +0000 UTC  job.command="curl http://my-app.flycast/api/scrape" job.position=0 job.schedule="00 22 * * *"

I have two machines:

OK. This looks like the reason; you have a syntax error in your schedule spec:

Ah, coolio. It looks like you have one machine for the runner process, which is probably not a bad thing for a scheduler. If you run more than one instance of a scheduler it will usually run all of your tasks several times, which in turn can produce some weird race conditions.

Are you sure this could be the reason why the job is not running? My understanding was that it tries to parse the cron expression as 6 fields format, but it fails. Then it tries to parse it as 5 fields format, which is successful and then the next job is scheduled:

DEBU[2025-03-10T13:32:14Z] job will run next at 2025-03-10 22:00:00 +0000 UTC  job.command="curl http://my-app.flycast/api/scrape" job.position=0 job.schedule="00 22 * * *"

But this job never gets executed.

Ah, I think you might be right. I’d amend the format then so it erases that error. It looks like it just needs seconds adding at the start:

00 00 22 * * * curl http://my-app.flycast/api/scrape

Alternatively there’s some scheduler debug approaches in the Supercronic README.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.