API Maker

The backend engine for the AI era

SchedulersEpisode 23 7:11 13 chapters November 2026

Schedulers: Cron Jobs Without a Cron Server

Code that runs on a clock: every minute, every night, or on weekdays at nine. No cron server, no double runs, and every run on record. Build a low stock alert for the buyers of Calm Home with intervals and cron expressions, run it now, pause it, give it a timeout, and see it run once per cluster with failover.

In the playlists The complete course Events & realtime

Chapters

What you will learn

  • A new scheduler, with an interval and a time zone
  • Cron expressions: six fields, checked as you type
  • Saved and running: the next runs and the past ones
  • Run now, pause and stop
  • A run that takes too long, and its timeout
  • Once per cluster, and when a server goes away
In the docsSchedulers
Transcript1030 words · click a time to play from there

Intro

A scheduler is code that runs on a clock: every minute, every night, or on weekdays at nine. There is no cron server, no run happens twice, and every run is recorded. In this video, Calm Home makes a low stock alert for its buyers.

Jobs, the usual way

Background jobs usually bring problems. A crontab sits on one server, and nobody remembers it. The same job runs on two servers, so two emails go out. There is no record of what ran and what failed. And a job dies with its server. With API Maker, a scheduler is a function with intervals. It runs once on the whole cluster. Every run is listed, with its time and its result.

And when a server goes away, another server takes over. In this video: a scheduler and its intervals, cron expressions, the run panel, run now, pause and stop, time limits, and one run for the whole cluster.

A scheduler and its intervals

Open APIs and Logic, then Schedulers. Click Add New. On the left is what it is. On the right is when it runs. The name is low_stock_alert, with a time limit of two minutes, and Active turned on. Add an interval: every minute, on the clock of Kolkata. Each interval has its own time zone. The run panel already counts down to the next run, and lists the next five.

What the server runs is what you see.

Cron expressions

Add a second interval, as a cron expression. Zero, zero, nine, any day, any month, Monday to Friday. The panel checks it while you type, with the rules of the server. Its next runs are Monday at nine o'clock, then Tuesday, and so on. There are six fields. The second comes first, then the minute, the hour, the day of the month, the month, and the day of the week.

Names work too, from jan to dec, and from sun to sat. So do presets, like @daily or @weekdays. Five fields, the way crontab.guru writes them, run at second zero.

The run panel

Now open the Code tab. The job reads the inventory of SQL Server, and keeps the rows at or under their reorder level. It names them from the products in MongoDB, and writes one alert into stock_alerts. It uses the same g as a custom API, in any of the eight languages. Save it. A server picks it up at once. It is Running, on the server video1, with its schedule and its time limit.

Open it again. It runs on video1, and counts down to the next minute. The minute comes, and the run is listed, with its time, its interval, and how long it took.

Run now

You do not need to wait for the clock. The test icon of the row opens the scheduler in API Testing, with its time limit as a header. Send runs it once. It finds fifteen products to order again, in milliseconds. The Logs tab shows the line that g.logger wrote. Now let us see what it wrote. Pick MongoDB, then catalog, then stock_alerts. Pick a query, and ask for the newest row.

We get one alert with fifteen products. Each one has its name from MongoDB, and its quantity from SQL Server.

Run time

After a few runs, the Scheduler List shows how the job is doing, from the numbers of Analytics. You see its average run time, and its runs over the day. A failure shows in red. One click opens the details of its runs: the p95 and the other percentiles, the slowest run, and the runs hour by hour. If a job slows down, you see it here, before anybody waits for its data.

Pause and stop

You can pause or stop a job without deleting anything. In the dialog, we switch off the interval every minute. Now the next run is Monday at nine. Untick Active, and nothing starts a run. Click Update. Every server stops it at once. It has no server now, so its dot is grey.

Timeouts

Here is a job that waits on a slow service, with a time limit of one minute. Open its run panel. It is running now, and its seconds count up. At one minute, it is stopped. The run is listed in red, with its error: API did not respond in sixty thousand milliseconds. The next minute starts its own run. So a slow run never holds up the next one.

Once per cluster

On a cluster, each scheduler runs on one server only. Every five seconds, each server writes in Redis that it is up. From that same list, each server works out the owner of every scheduler, with rendezvous hashing. They agree without talking, and the schedulers are spread evenly. The owner holds a key in Redis for twenty seconds, and renews it while it runs. So a scheduler never runs on two servers at once.

Now a server goes away. If it stops cleanly, it gives its keys back, and the others take its schedulers within five seconds. If it crashes, its keys expire, and the others take over within twenty seconds. And only its share moves. The schedulers of the other servers stay where they are.

Good to know

Good to know. The next run may be on another server. So keep what a run needs in the cache, not in memory. Schedulers are files in Git, and they travel with a pull. A log profile records every run, and its answer too with Log Response. Schedulers of a developer account never run, so developers can work without firing real jobs.

Built on standards

Every job has a name, intervals with time zones, a time limit, and a record of its runs. What the panel shows is what runs, because the same cron engine reads both. And an AI assistant writes a job like a custom API: one function, with the same g.

Recap

To sum up. A scheduler is a function with intervals, each with a time zone. Cron expressions are checked while you type. The next runs and the past runs are side by side. You can run now, pause, stop, and set a time limit. And it runs once for the cluster, with failover. Next: authorization, who can call what. API Maker. Build faster, spend smarter, deliver better.