Scheduled Jobs

Server-side cron jobs without your own backend

Overview

Create scheduled jobs that run on a cron schedule in your project’s sandbox. No need to manage your own server — define the handler code and schedule, and Recursiv executes it automatically.

All job methods are available on r.jobs.

Methods

MethodDescription
create(input)Create a scheduled job.
list()List all scheduled jobs.
update(id, input)Update a job (schedule, handler, status).
delete(id)Delete a scheduled job.

Create a job

1const { data: job } = await r.jobs.create({
2 name: 'daily-digest',
3 cron: '0 8 * * *', // Every day at 8am
4 project_id: 'proj_123',
5 handler_code: `async () => {
6 // This runs in your project sandbox on schedule
7 const db = require('pg');
8 const client = new db.Client({ connectionString: process.env.DATABASE_URL });
9 await client.connect();
10 const { rows } = await client.query('SELECT COUNT(*) FROM orders WHERE created_at > NOW() - INTERVAL \\'1 day\\'');
11 console.log('Orders today:', rows[0].count);
12 await client.end();
13 }`,
14 timezone: 'America/New_York',
15});
16
17console.log(job.id); // Job ID
18console.log(job.next_run_at); // Next scheduled execution

List jobs

1const { data: jobs } = await r.jobs.list();
2
3for (const job of jobs) {
4 console.log(`${job.name} — ${job.cron} — ${job.status} — last run: ${job.last_run_at}`);
5 if (job.last_error) console.log(` Error: ${job.last_error}`);
6}

Pause / resume a job

1// Pause
2await r.jobs.update('job_id', { status: 'paused' });
3
4// Resume
5await r.jobs.update('job_id', { status: 'active' });

Update schedule or handler

1await r.jobs.update('job_id', {
2 cron: '0 */6 * * *', // Every 6 hours
3 handler_code: `async () => { /* updated logic */ }`,
4});

Delete a job

1await r.jobs.delete('job_id');

Cron expression reference

ExpressionSchedule
* * * * *Every minute
0 * * * *Every hour
0 8 * * *Every day at 8am
0 0 * * 1Every Monday at midnight
0 0 1 * *First day of every month

Job handlers run in your project’s E2B sandbox with a 60-second timeout. They have access to your project’s environment variables and database.