My Upwork Scout dashboard has a line of copy under the job list: "Scans run every 15 minutes." I wrote it in July, the same evening I committed the workflow that was supposed to make it true. This week I finally pulled the run history for that workflow and counted.
It has run 1,772 times in 150 days. At one run every 15 minutes plus one daily digest, that number should be about 14,500. Every single run was green.
This is a build-log about what a cron expression actually promises on GitHub Actions, and the parts of my code that quietly depended on the promise being kept.
The setup
Upwork Scout scrapes Upwork categories, filters and AI-scores the jobs per user, and emails matches. The engine is one secret-guarded endpoint, /api/cron/scan, on Vercel. Something has to call it on a schedule, and I picked the thing that was already there: a GitHub Actions workflow in the same repo.
on:
schedule:
- cron: "*/15 * * * *" # scan every 15 minutes
- cron: "0 8 * * *" # 08:00 UTC daily, this one flushes digests
The job is a single curl. It prints the HTTP code and the JSON stats, and fails only if the code is not 200. Each run takes about nine seconds.
What the history says
I exported every run with gh run list --json createdAt and bucketed them by day.
| Period | Runs per day | Expected |
|---|---|---|
| First week of July | 10 to 18 | 97 |
| Mid August (best stretch) | 35 to 52 | 97 |
| From August 27 onward | 1 to 10 | 97 |
| November average | about 4.6 | 97 |
Over the last 30 days the median gap between two runs is 5 hours 21 minutes. The longest is 18.5 hours.
The August 27 cliff is the part I cannot explain. The workflow file has not changed since July 5. The repo got commits that week like every other week. One day it ran 23 times, the next day 3, and it never came back. I am not going to invent a cause for it here. What I can say is that GitHub's own docs warn that scheduled workflows can be delayed when load is high, that the start of every hour is a high-load time, and that some queued runs can be dropped. My */15 fires on minute 0 of every hour, and my digest fires at exactly 08:00. I put both of my schedules on the busiest minutes there are.
The digest has never been on time
The digest schedule is the cleaner experiment, because the workflow logs whether a run carried the digest flag. I pulled the logs for the last 60 runs. Fifteen of them were digest runs, one per day from November 17 to December 1, so none were dropped. Not one of them ran at 08:00.
- The earliest arrived at 15:53 UTC, almost 8 hours late.
- Most landed between 16:00 and 20:00 UTC.
- The one scheduled for December 1 ran at 05:21 UTC on December 2, more than 21 hours late.
I picked 08:00 UTC so the digest would land in the morning for most of my users. In practice it lands in the evening, and occasionally the next day.
Code that assumed the clock was honest
A late scheduler would be a minor annoyance if my code did not care how often it ran. It cares in two places.
Page size times cadence is your coverage ceiling
Each run fetches the newest few jobs per category:
const PER_RUN_LIMIT = Number(process.env.SCAN_ITEMS_PER_CATEGORY || 5);
Five newest jobs, every 15 minutes, means up to 480 slots per category per day. That was the design. At four runs a day it is 20 slots. The fetch asks the scraper for sort: "newest", so it only ever sees the five newest jobs at the moment it happens to wake up. In a busy category like web development, five posts is a thin slice of a five-hour gap. Everything posted in between is invisible. There is no error for that, because nothing failed. The run just looked at a smaller window than I thought it did.
My spend budget only works because the scheduler is broken
This is the one that made me laugh, then made me uncomfortable. There is a platform-wide daily fetch budget so a bug cannot burn my scraping bill:
const DAILY_BUDGET = Number(process.env.GLOBAL_DAILY_FETCH_BUDGET || 150);
const remaining = DAILY_BUDGET - spend;
if (remaining <= 0) activeCats = [];
else activeCats = activeCats.slice(0, Math.max(1, Math.floor(remaining / PER_RUN_LIMIT)));
Every one of my nine categories has at least one subscriber right now, so a full run can bill up to 45 items. Walk that through at the cadence I actually asked for, starting from midnight UTC:
| Run (UTC) | Spent before | Categories allowed | Spent after (worst case) |
|---|---|---|---|
| 00:00 | 0 | 9 | 45 |
| 00:15 | 45 | 9 | 90 |
| 00:30 | 90 | 9 | 135 |
| 00:45 | 135 | 3 | 150 |
| 01:00 onward | 150 | 0 | 150 |
If GitHub had honored my cron, the whole day's budget would be gone by 00:45 UTC, and the scanner would sit idle for the next 23 hours while the dashboard said "Scans run every 15 minutes." The budget is a total, and I spend it greedily from the top of the day. The only reason this design has not starved the product is that the scheduler underdelivers by about 95%, so four or five runs a day fit inside it.
Two bugs that cancel each other out are worse than one bug. Fixing either one alone makes things worse: get a reliable scheduler and the budget dies at 1 AM, raise the budget and you only pay more for the same sparse sampling.
What I am changing
None of this is shipped yet. This is the plan, in order:
- Turn the budget into a rate. Instead of "150 per day, first come first served", allow spend in proportion to how much of the UTC day has passed. A late run inherits the allowance that built up while nothing ran, and an on-time run cannot drain the day.
const dayStart = Date.parse(`${today}T00:00:00Z`);
const elapsed = (now - dayStart) / 86_400_000; // 0..1
const allowedSoFar = Math.ceil(DAILY_BUDGET * elapsed);
const remainingNow = Math.max(0, allowedSoFar - spend);
Size the fetch by the gap, not the clock. The scan already writes
lastRunAtto Firestore at the end of every run. If the last run was five hours ago, five items per category is the wrong page size, and the run should know that.Move the clock off GitHub. My own README already recommends an external pinger for exactly this reason, and I ignored it because Actions was right there. Actions can stay as a backup caller, since the endpoint takes a lock and is safe to call twice. If I keep it at all, it moves off minute 0, something like
7,22,37,52 * * * *.Alert on the gap, not the status. Green Actions runs told me each run succeeded. They never told me how many runs happened. A tiny check that complains when
lastRunAtis older than 45 minutes would have caught this in August.Fix the copy. Until the cadence is measured and real, the dashboard should not say "every 15 minutes."
The lesson I keep relearning
A cron expression on a shared runner is a request, not a contract. The scheduler will tell you every run it did is fine. It will not tell you about the runs it did not do, and it will not tell you that your budget, your page size and your marketing copy were all built on a number it never agreed to.
I wrote a while ago about my cron job returning 200 when every fetch fails. This is the same blind spot from the other side. That post was about runs lying about their result. This one is about not counting the runs at all. And once there are two callers instead of one, overlapping runs become normal, so the dedupe work from you can retry a write, you cannot retry an email matters more, not less.
If you run production jobs off GitHub Actions schedule, have you ever counted how many actually fired? I am curious whether 4 a day out of 96 is unusual or just what nobody checks.
Top comments (2)
Two cheap changes for this. First, move the schedule off the busy marks:
7,22,37,52 * * * *instead of*/15, since GitHub's own docs name the top of the hour as the heavy-load time. Second, make the endpoint carry a cursor (the time of the last successful scan) and derive the work from the time since that cursor, so a late or dropped tick means a bigger batch instead of a hole.The cursor also gives you something to alert on: the age of the last successful scan. The dashboard line could then say "last scan 5 h ago" instead of promising an interval, and a stale-scan alert catches the next silent drop. If you need a schedule that is actually on time, a Cloudflare Workers cron trigger or a plain external pinger tends to be tighter than the Actions scheduler.
Thanks, this is a really useful pair of suggestions. The cursor one especially: right now every run fetches a fixed 5 newest jobs per category no matter how long it has been since the last run, which is exactly why a dropped tick turns into a hole instead of a bigger batch.
There is already a timestamp I can build on,
lastRunAtin ameta/scandoc, but it gets written at the end of every run, including runs that fetched nothing. So it is a "last run", not a "last successful scan". Splitting those two and alerting on the age of the successful one is the version I want.Agreed on the dashboard copy too. "Last scan 5h ago" is honest in a way "every 15 minutes" is not. And moving off minute 0 is a one-line change. My README already recommends cron-job.org as the pinger, I just never moved off the Actions schedule I set up first.