Functions and configuration
Scheduled jobs
Run Project work on a schedule with cron expressions, see every registered job, and start any job by hand when you need it now.
Create a scheduled job
- Open Functions and select New function, then choose the Scheduled job template.
- Write the work the job should do.
- In the Triggers tab, keep Cron schedule selected and choose a preset (Every minute, Hourly, Daily, Weekly) or type your own expression.
- Save the function and use Run function now once to check the result.
- Open Scheduled jobs in the Project menu to confirm the job is registered.
Cron expressions
An expression has five parts: minute, hour, day of month, month, and day of week. Times use UTC.
| Expression | Runs |
|---|---|
* * * * * | Every minute |
*/15 * * * * | Every 15 minutes |
0 * * * * | At the start of every hour |
0 0 * * * | Every day at 00:00 UTC |
30 2 * * 1 | Every Monday at 02:30 UTC |
0 9 1 * * | At 09:00 UTC on the first day of each month |
Example: nightly cleanup
// Trigger: Cron schedule, 0 3 * * *
$db.execute(
"DELETE FROM sessions WHERE expires_at < now() - interval '7 days'",
{},
);
console.log("cleanup finished", $utils.now());
({ done: true })List and run jobs from a server
const jobs = await rb.admin.crons.list(); // [{ id, expression }]
await rb.admin.crons.run(jobs[0].id); // runs it nowOperate safely
- Make each run idempotent, so running it twice gives the same result.
- Process work in small batches and keep each run under the function timeout.
- Avoid scheduling a job more often than it takes to finish.
- Log what each run did, then check the function's Logs tab after the first few runs.
- Pause the function to stop the schedule without losing the code.
Found something wrong on this page?
Fix it yourself. The link below opens this file in GitHub's editor and forks the repository for you if you need one, and your change becomes a pull request without leaving the browser.