Skip to content

Announcing function intervals: run functions every N minutes_

Appwrite Functions can now run on an interval as an alternative to cron. Set how often a function runs, and Appwrite picks when within each interval it starts.

4 min read

Most scheduled functions don't need to run at an exact minute. A job that syncs data, refreshes a cache or cleans up old records needs to run often enough, not at :00 on the hour. Cron makes you pick an exact time anyway, so most of these jobs end up on 0 * * * * or */15 * * * *, starting at the same moment as every other function with the same schedule.

Appwrite Functions now support intervals. You set how often a function runs, and Appwrite decides when within each interval it starts.

How intervals work

An interval is a number of minutes. Think of it as cron where Appwrite picks the time for you: an interval of 60 runs at the same point in every hour, such as 37 minutes and 21 seconds past, chosen for your function.

Text
every 60 minutes  →  14:37:21, 15:37:21, 16:37:21, ...

Each function gets its own time within the interval, so functions with the same interval spread out across it instead of all starting at once. Your scheduled work starts on time without queueing behind every other function scheduled for the top of the hour.

Run times are fixed to the UTC clock, not counted from when you save the function. The first run can be up to one full interval away, and an interval that isn't a factor or multiple of 60, such as 90 minutes, doesn't run at the same time every hour.

A function uses either an interval or a cron expression:

IntervalCron
You setHow often, in minutesExact times
Runs atA fixed time Appwrite picks within each intervalThe times in the expression (up to 5 minutes later on the Free and Education plans)
Best forSyncs, cleanups, polling, cache refreshesReports, digests, anything tied to the clock

Set an interval in the Console

Open your function, go to Settings > Schedule, and choose Interval. Pick a preset such as every 15 minutes, every hour or every day, or enter your own number of minutes.

Set an interval with a Server SDK or the CLI

Pass interval when you create or update a function:

JavaScript
import { Client, Functions } from 'node-appwrite';

const client = new Client()
    .setEndpoint('https://<REGION>.cloud.appwrite.io/v1')
    .setProject('<PROJECT_ID>')
    .setKey('<API_KEY>');

const functions = new Functions(client);

await functions.update({
    functionId: '<FUNCTION_ID>',
    name: 'Sync orders', // name is required by update
    interval: 30 // every 30 minutes
});

With the Appwrite CLI 28.3.0 or later, pass --interval, or set "interval" on the function in appwrite.config.json and run appwrite push functions:

Bash
appwrite functions update --function-id <FUNCTION_ID> --name "Sync orders" --interval 30

Set interval to 0 to stop it. An update that leaves interval out keeps the current one, so existing code that updates other settings won't clear it. Setting the schedule parameter (a cron expression) switches the function back to cron.

Plans

On Appwrite Cloud, paid plans support intervals from 1 minute. The Free and Education plans support intervals of 60 minutes or longer. Cron expressions work the same as before on every plan.

Intervals are available on Appwrite Cloud today and come to self-hosted Appwrite in the next release.

Resources

Read next

Ready to build?_