Deploy cron-worker-primitives

Deploy and Host simple Python cron jobs and background workers with Railway

Deploy cron-worker-primitives

Deploy and Host Python Cron and Worker Examples on Railway

Deploy two small Python scripts: a daily URL check and a persistent polling worker. Both use Python's standard library and log their results.

About Hosting Python Cron and Worker Examples

The cron-check service runs python check_once.py daily at 09:00 UTC, then exits. The worker-check service runs python worker.py, checking immediately and waiting 60 seconds after each attempt. Neither needs a public domain, database, or queue.

Each service has TARGET_URL, defaulting to https://example.com. Set it to a public HTTP(S) endpoint without credentials. A final HTTP 2xx response counts as success. Requests use a ten-second blocking-operation timeout. The worker records failed checks and continues; it stops cleanly on SIGTERM/SIGINT.

Why Deploy Python Cron and Worker Examples on Railway

Railway provides native cron schedules, persistent services, deployment logs, and process restart controls. This example makes the difference between a scheduled task and a persistent worker easy to inspect.

Common Use Cases

  • Learn native cron scheduling with a script that runs and exits.
  • Start a polling worker without adding a queue.
  • Replace the URL check with a feed fetch, data sync, or other background task.

Dependencies for Python Cron and Worker Examples

  • Railway account and capacity for one persistent service plus a scheduled task.
  • Outbound HTTP(S) access to your chosen target.

Deployment Dependencies

Python 3.13 is supplied by the Docker image. No pip packages, database, Redis, public domains, or volumes are required. The optional TypeScript IaC configuration in the source repository is for managing infrastructure; Node.js is not used by the running services.

The cron uses restart policy Never. The worker uses On Failure with ten restarts and Serverless disabled. These settings do not provide durable job storage or monitoring alerts. Review task idempotency, alerting, and downstream limits before adapting the scripts for production actions. Stop deployments you no longer need; the worker consumes resources while running.


Template Content

More templates in this category

View Template
N8N Main + Worker
Deploy and Host N8N with Inactive worker.

jakemerson
120
View Template
Evolution API with n8n
Automate WhatsApp workflows with Evolution API, n8n, and Postgres.

codestorm
107
View Template
Postgres Backup
Cron-based PostgreSQL backup to bucket storage

Railway Templates
868