---
title: "Run Scheduled and Recurring Tasks with Cron"
description: "Cron runs commands on time-based schedules but keeps no job history, has no retries and does no concurrency control, so reliability depends on the job itself."
url: "https://swe.quest/articles/run-scheduled-and-recurring-tasks-with-cron-ca49b6813f0599a8"
canonical: "https://blog.railway.com/p/run-scheduled-and-recurring-tasks-with-cron"
source: "Railway"
published: "2025-11-26"
difficulty: "medium"
kind: "How-to"
reading_minutes: 10
tags: ["scheduling","deployment","postgres"]
---

# Run Scheduled and Recurring Tasks with Cron

A post on [Railway](https://swe.quest/sources/railway.md), published 2025-11-26, 10 min read, How-to. Original: [https://blog.railway.com/p/run-scheduled-and-recurring-tasks-with-cron](https://blog.railway.com/p/run-scheduled-and-recurring-tasks-with-cron)

## Summary

Cron runs commands on time-based schedules but keeps no job history, has no retries and does no concurrency control, so reliability depends on the job itself. The guide covers the five-field schedule syntax, including the day-of-month/weekday OR pitfall and timezone/DST issues, and recommends idempotent upserts, structured start/success/error logs, explicit connection cleanup, and Postgres advisory locks to prevent overlapping runs. On Railway, cron triggers a service's start command in UTC with a 5-minute minimum interval and a single active execution. A process left alive by open handles or pending promises causes later runs to be skipped.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Scheduling](https://swe.quest/tags/scheduling.md) (Distributed systems)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)
- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)

## Prerequisites

- Unix command-line basics
- Node.js async/await ([easy posts on JavaScript](https://swe.quest/tags/javascript.md?difficulty=easy))

## Keywords

cron, Railway, pg\_try\_advisory\_lock, crontab.guru, node-cron, PostgreSQL

## Related posts

- [Postgres as a CRON Server](https://swe.quest/articles/postgres-as-a-cron-server-d7e215165e9a3fbe.md): Supabase · 2021-03-05 · Medium · 6 min read · PostgreSQL, Scheduling, SQL
  Postgres can act as a cron server by combining the pg\_cron extension for scheduling with the pgsql-http extension for outbound HTTP calls, letting a scheduled SQL statement POST to a webhook every minute.
- [How to fix missing table errors in pg\_cron](https://swe.quest/articles/how-to-fix-missing-table-errors-in-pg-cron-3e70d0e00b3759de.md): Neon · 2025-07-14 · Medium · 8 min read · PostgreSQL, Scheduling, SQL
  pg\_cron stores scheduled jobs as raw SQL text, separate from Postgres' system catalogs, so dropping a table leaves jobs that fail every run with "relation does not exist" and fill cron.job\_run\_details with errors.
- [Cron Jobs on Railway](https://swe.quest/articles/cron-jobs-on-railway-97c5484f2a611343.md): Railway · 2022-08-18 · Medium · 3 min read · Deployment, TypeScript, Scheduling, Cloud platforms
  Before native cron support existed, Railway cron jobs could be run as an ordinary long-lived service that schedules work with a language-level library.
- [Your Neon Functions can now run on a schedule](https://swe.quest/articles/your-neon-functions-can-now-run-on-a-schedule-72b4a206b2b5554b.md): Neon · 2026-09-21 · Medium · 5 min read · Serverless, PostgreSQL, Scheduling
  Neon Function Triggers let Neon invoke a deployed Node.js function on a cron schedule.
- [Executing Cron Scripts Reliably At Scale](https://swe.quest/articles/executing-cron-scripts-reliably-at-scale-300d2911de10f9b3.md): Slack Engineering · 2023-09-28 · Medium · 5 min read · Scheduling, System design, Kubernetes, Go, Queues & messaging
  Slack replaced a single cron box running all scripts from one crontab with a distributed cron execution service built mostly from existing infrastructure.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
