Scheduled Jobs on Raseef: Riyadh Time, Deadlines and Safe Retries

Convert Riyadh times to UTC cron, size run deadlines for retries, and write Node.js jobs that exit cleanly, survive skipped runs and are safe to run twice on Raseef.

Why a "midnight" job runs at the wrong time

You schedule a nightly report for 0 0 * * *, expecting midnight in Riyadh. It runs at 03:00 local time instead, and the "yesterday" it reports on is not the day your team expected. Nothing is broken: Raseef schedules jobs in UTC.

This guide is for teams moving cron work, such as reports, cleanups and syncs, to Raseef scheduled jobs. It covers how to translate Riyadh times correctly, how to size the run deadline and retries, and how to write a Node.js job that finishes cleanly and is safe to run twice.

How Raseef scheduled jobs behave

According to the scheduled jobs documentation, a scheduled job runs a container on a schedule and stops it when it finishes:

  • The schedule uses five cron fields (minute, hour, day of month, month, day of week), in UTC. Shortcuts such as @daily and a seconds field are not supported.
  • Run deadline is 1 to 86,400 seconds (300 for a new job). Retries are 0 to 3 (0 for a new job).
  • A run does not start while the previous one is still running.
  • The deadline covers the run and its retries together. When it passes, the run is stopped, counts as failed and is not retried.
  • A run that could not start on time is skipped if it is more than 60 seconds late.
  • A job has no port and no volume, and runs one replica. Its runs and their outcomes are listed in the service panel.

To create one, choose Create → Scheduled job in a project, enter the image, a name and the schedule, then Create and deploy. To turn an existing service into a job, stop it, then switch its settings from Always on to Scheduled.

Translate Riyadh time to UTC

Riyadh uses UTC+3 all year, with no daylight saving time (timeanddate.com lists no clock changes in 2020–2029). Subtract three hours. When the result falls before midnight, the day also moves back, which matters for weekly schedules:

You want (Riyadh)Cron (UTC)Note
Every day at 00:000 21 * * *Matches the docs' own example
Every day at 06:000 3 * * *
Thursday at 10:000 7 * * 4Same day
Sunday at 01:3030 22 * * 6Runs on Saturday in UTC
First of the month at 00:000 21 * * * plus a check in codeSee below

The last row has no exact five-field equivalent: midnight on the 1st in Riyadh is 21:00 UTC on the last day of the previous month, and that day varies between 28 and 31. Run daily at 0 21 * * * and let the job exit early unless the Riyadh date is the 1st.

We checked these conversions on 29 November 2026 with the helper below in a JavaScript runtime. All nine assertions passed, including the date boundary (20:59:59 UTC is still 29 November in Riyadh; 21:00:00 UTC is 30 November), the Saturday shift for Sunday 01:30, and a leap-day case (21:00 UTC on 29 February 2028 is 1 March in Riyadh). This tests our conversion logic only, not Raseef's scheduler.

// Riyadh is UTC+3 all year (no daylight saving time)
function riyadhDay(date = new Date()) {
  return new Date(date.getTime() + 3 * 60 * 60 * 1000).toISOString().slice(0, 10);
}

// hour/minute in Riyadh time; dow: 0 = Sunday … 6 = Saturday (optional)
function riyadhToUtcCron(hour, minute, dow) {
  let h = hour - 3;
  let shift = 0;
  if (h < 0) { h += 24; shift = -1; }
  const day = dow === undefined ? '*' : String((dow + shift + 7) % 7);
  return `${minute} ${h} * * ${day}`;
}

riyadhToUtcCron(1, 30, 0); // "30 22 * * 6"
riyadhDay(new Date('2026-11-30T21:00:00Z')).endsWith('-01'); // true: 1 December in Riyadh

Size the deadline for the retries you choose

Because the deadline covers every attempt together, a 300-second deadline with 2 retries does not give each attempt 300 seconds. If an attempt can take up to T seconds, a deadline below roughly (retries + 1) × T plus start-up time can cut off the last retry. Then the run counts as failed without the retry you configured.

Practical rules:

  1. Measure how long the job takes on realistic data in a staging environment before choosing numbers.
  2. Give each attempt its own internal time budget, shorter than its share of the deadline, so the job fails with a clear log line instead of being stopped silently.
  3. Use retries for transient failures (a network call timing out), not for bugs. A job that fails on bad data will fail the same way three times.

Write a job that finishes and can run twice

A job must exit when its work is done. An open database pool or a forgotten timer can keep a Node.js process alive until the deadline stops it, and that run then counts as failed. Retries also mean the same work can run more than once, so make it idempotent.

// job.mjs: one run, then exit (Node.js, ES module)
const BUDGET_MS = Number(process.env.JOB_BUDGET_MS || 240000); // below the default 300 s deadline

function riyadhDay(date = new Date()) {
  return new Date(date.getTime() + 3 * 60 * 60 * 1000).toISOString().slice(0, 10);
}

async function run(signal) {
  const day = riyadhDay();
  console.log(JSON.stringify({ event: 'job_start', day }));
  // Do the work for `day` only. Pass `signal` to fetch() and to clients that accept it.
  // Save results with an upsert keyed by `day`, so a retry overwrites instead of duplicating.
  console.log(JSON.stringify({ event: 'job_done', day }));
}

const controller = new AbortController();
const timer = setTimeout(() => controller.abort(), BUDGET_MS);
try {
  await run(controller.signal);
} catch (err) {
  console.error(JSON.stringify({ event: 'job_failed', message: err.message }));
  process.exitCode = 1;
} finally {
  clearTimeout(timer);
  // Close database pools and other open handles here so the process can end.
}

Setting process.exitCode to a non-zero value is the conventional way for a process to report failure. Confirm on a staging run that a forced failure appears as a failed run in the service panel before relying on retries.

For PostgreSQL, an upsert keyed by the business day keeps a retried or repeated run from creating duplicates:

CREATE TABLE IF NOT EXISTS daily_reports (
  report_day date PRIMARY KEY,
  orders_count integer NOT NULL,
  generated_at timestamptz NOT NULL DEFAULT now()
);

INSERT INTO daily_reports (report_day, orders_count)
VALUES ($1, $2)
ON CONFLICT (report_day)
DO UPDATE SET orders_count = EXCLUDED.orders_count, generated_at = now();

Plan for skipped runs

Two documented rules mean a scheduled time can pass without a run: a run will not start while the previous one is still running, and a run more than 60 seconds late is skipped. A job that always processes "yesterday" will then silently leave a gap.

Instead, store the last day the job completed, for example in the same table, and process every pending day up to the current one. A skipped or failed night is then picked up by the next successful run.

Configuration and operations checklist

  • Variables: a job reads environment variables like any service. Variables apply on the next deployment; saving does not change the running version. Our guide on environment variables explains save, deploy and restart.
  • Databases: reference connection values such as DATABASE_URL=${{ db.DATABASE_URL }} instead of copying them; references stay within one environment (variables docs). The jobs page says a job has no networking of its own, so nothing can call it. Verify its outbound connection to your database on a staging run. For private addresses in general, see our private networking guide.
  • Files: a job has no volume. Write results to a database or external storage, not local disk. For services that do need disk, see persistent volumes.
  • Email reports: outbound port 25 is blocked; send through a provider on 587 or 465 (outbound traffic).
  • Logs: app logs are kept 7 days, with the last 5,000 lines per deployment and lines up to 2,000 characters (limits). Prefer one compact JSON summary per run, and keep long-term run history in your database if you need it beyond a week. Never log secrets.

What this guide does not claim

The platform behavior above comes from Raseef's current documentation, checked on 29 November 2026. Our test covered the time-conversion helper only. We did not run a scheduled job on Raseef for this article, measure run timing, or test how the platform reports exit codes, so verify those on a staging job.

Sources: Scheduled jobs, Limits, Variables, Core concepts, Outbound traffic, Riyadh time zone and Node.js process.

Raseef currently runs a private pilot. To move your scheduled work onto servers in Saudi Arabia, request access.