A step-by-step guide to moving Railway cron services to AWS: how Railway runs and skips scheduled services, the EventBridge Scheduler version with Fargate or Lambda, and a TypeScript version where each schedule sits next to the code it calls.

A Railway cron job is a regular service with a crontab expression in its settings, started on that UTC schedule and expected to exit when done. If a job leaves a Postgres connection open, Railway quietly skips every later run.
Moving the backend to AWS means each of those services needs a new home. This guide maps Railway cron jobs to AWS, then shows the same jobs declared in code.
The Railway behavior comes from its cron jobs reference, checked on November 20, 2026. Schedule types, time zones and retry policies are in the EventBridge Scheduler user guide, and the 15-minute ceiling is in the Lambda quotas.
Open each service in the Railway project that has a value under Cron Schedule and write down four things: the crontab expression, the start command (for example node jobs/prune-sessions.js), the variables it reads and the longest run you can find in its deployment history. Check the history for runs that stayed Active far longer than the job should take, since those are the jobs that have been skipping schedules without anyone noticing. Note as well whether a job writes files to a Railway volume, because a scheduled task on AWS has no volume to share with the web service and those files belong in S3.
Jobs that finish in seconds or minutes fit Lambda behind an EventBridge Scheduler schedule, packaged as a function with its own copy of the database connection settings. Anything longer, or anything that needs the same container image as the web service, fits a Fargate task, and the schedule's target becomes ECS RunTask with the cluster, task definition, subnets and security group spelled out. Each schedule also needs an execution role that EventBridge Scheduler assumes, with ecs:RunTask and iam:PassRole for the task's roles, or lambda:InvokeFunction for a function.
Railway's skip-if-running behavior does not come along, since EventBridge Scheduler starts the next task on every tick, so a job that runs every 30 minutes and once took 40 will run twice at the same time, and anything that is unsafe to overlap needs a guard such as pg_try_advisory_lock at the start, or a design where a second run finds nothing left to do. The schedule's retry policy can resend a failed invocation, with up to 185 attempts and a maximum event age of 24 hours, per the retry policy reference.
Encore brings infrastructure from code, and a cron job becomes a CronJob that points at an API endpoint in the service that owns the work, instead of a separate service with its own start command. Per the AWS infrastructure docs, cron runs as signed requests from the Encore platform and needs no extra infrastructure in your account, so there is no scheduler, execution role or task definition per job. The database the job queries runs on RDS and the bucket on S3, both provisioned in your account from the same code.

Run in your terminal to get started locally.
Two Railway cron services, a session cleanup every 30 minutes and a nightly CSV export that used to write to a volume:
// jobs/jobs.ts
import { api } from "encore.dev/api";
import { CronJob } from "encore.dev/cron";
import { SQLDatabase } from "encore.dev/storage/sqldb";
import { Bucket } from "encore.dev/storage/objects";
import log from "encore.dev/log";
// The same Postgres the web service uses, provisioned as RDS on AWS.
const db = new SQLDatabase("app", { migrations: "./migrations" });
// Daily CSV exports that used to be written to a Railway volume.
export const exportFiles = new Bucket("daily-exports", { versioned: false });
// Was a Railway cron service: start command `node jobs/prune-sessions.js`,
// schedule `*/30 * * * *`.
export const pruneSessions = api(
{ expose: false, method: "POST", path: "/internal/prune-sessions" },
async (): Promise<{ deleted: number }> => {
const row = await db.queryRow<{ deleted: number }>`
WITH gone AS (
DELETE FROM sessions WHERE expires_at < now() RETURNING 1
)
SELECT count(*)::int AS deleted FROM gone
`;
return { deleted: row?.deleted ?? 0 };
},
);
const _prune = new CronJob("prune-sessions", {
title: "Delete expired sessions",
every: "30m",
endpoint: pruneSessions,
});
// Was a Railway cron service: `node jobs/export-signups.js` at `0 2 * * *`.
export const exportSignups = api(
{ expose: false, method: "POST", path: "/internal/export-signups" },
async (): Promise<{ key: string; rows: number; skipped: boolean }> => {
const day = new Date(Date.now() - 86_400_000).toISOString().slice(0, 10);
const key = `signups/${day}.csv`;
// A second call for the same day finds the file and stops.
if (await exportFiles.exists(key)) return { key, rows: 0, skipped: true };
const lines = ["id,email,created_at"];
for await (const u of db.query<{ id: number; email: string; created_at: Date }>`
SELECT id, email, created_at FROM users
WHERE created_at >= ${day}::date AND created_at < ${day}::date + 1
ORDER BY id
`) {
lines.push(`${u.id},${u.email},${u.created_at.toISOString()}`);
}
await exportFiles.upload(key, Buffer.from(lines.join("\n")), { contentType: "text/csv" });
log.info("exported signups", { key, rows: lines.length - 1 });
return { key, rows: lines.length - 1, skipped: false };
},
);
const _export = new CronJob("export-signups", {
title: "Export yesterday's signups to CSV",
schedule: "0 2 * * *",
endpoint: exportSignups,
});
-- jobs/migrations/1_init.up.sql
CREATE TABLE users (
id BIGSERIAL PRIMARY KEY,
email TEXT NOT NULL UNIQUE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now()
);
CREATE TABLE sessions (
id TEXT PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES users(id),
expires_at TIMESTAMPTZ NOT NULL
);
CREATE INDEX sessions_expires_at_idx ON sessions (expires_at);
There is no process to exit and no connection to close at the end, which removes the most common reason Railway cron runs get skipped, and the delete and the existence check make both endpoints safe to call twice, which the cron jobs docs ask for since a call can repeat. Schedules are in UTC as on Railway, and every intervals have to divide 24 hours evenly. Cron jobs do not run during local development, so you test them with encore run by calling POST /internal/prune-sessions and POST /internal/export-signups directly, where encore run also starts Postgres and a local bucket. The object storage docs cover the bucket API used for the export.
To deploy, connect your AWS account as described in Connect your cloud account and push with git push encore.
A coding agent that adds a weekly digest writes one endpoint and one CronJob in the same file, runs it locally by calling the endpoint, and the next deploy registers the schedule without a Railway service or an AWS schedule to create by hand.
Best fit: Backends leaving Railway for their own AWS account that want each scheduled job next to the code it runs, with the database and files in the same account.
Deploy the AWS version while the Railway cron service still exists, then clear its Cron Schedule setting right before the next AWS run, so the job never runs in both places in the same window. Compare the first few runs against Railway's deployment history, and keep the Railway service for one full cycle (a week for a weekly job) before deleting it. Jobs that send email or charge cards deserve a dry-run flag for the first run on AWS.
EventBridge Scheduler starting an ECS task on Fargate is the closest match, since Railway starts a whole service on a schedule and expects it to exit. For jobs that finish within 15 minutes, EventBridge Scheduler can invoke a Lambda function instead.
Railway skips a scheduled run when the previous execution is still active, which usually means the process did not exit because a database connection or timer was left open. Close every connection at the end of the job, or move the job to a platform that calls an endpoint instead of starting a process.
Yes. EventBridge Scheduler accepts rate expressions down to one minute, while Railway requires scheduled runs to be at least 5 minutes apart. A job that runs every minute should still be safe to overlap, since the scheduler does not wait for the previous run.
With Encore you declare a CronJob in application code that points at an API endpoint, and once deployed the Encore platform calls that endpoint on the schedule, with no scheduler resources in your AWS account. Cron jobs do not run locally, so you test them by calling the endpoint directly.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.