惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

罗磊的独立博客
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
V
Visual Studio Blog
MyScale Blog
MyScale Blog
M
MIT News - Artificial intelligence
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
博客园 - 【当耐特】
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
宝玉的分享
宝玉的分享
Engineering at Meta
Engineering at Meta
WordPress大学
WordPress大学
Google DeepMind News
Google DeepMind News
C
Check Point Blog
Last Week in AI
Last Week in AI
F
Fortinet All Blogs
博客园 - 聂微东
Blog — PlanetScale
Blog — PlanetScale
H
Help Net Security
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG

Railway Blog

Where Railway is, and where it's going (Summer 2026) PaaS vs IaaS vs SaaS: What Each Means and Who Should Pick What in 2026 The Best Continuous Deployment Tools in 2026 The Best PaaS for Multi-Region Deployments in 2026 The Best Platforms for Monorepo Deployments in 2026 Compliance Isn't a Feature, It's a Posture What is BYOC (Bring Your Own Cloud)? A Developer's Guide for 2026 The Best Managed Kubernetes Hosting in 2026 The Best Container Registries in 2026 The Vanilla Cloud Tax: What Rolling Your Own on AWS Actually Costs What is a PaaS? A Developer's Guide for 2026 The Best Cloud Observability and Logging Tools in 2026 The Best PostgreSQL Hosting for Developers in 2026 The Best Multi-Region Hosting Platforms in 2026 The Best Platforms to Deploy AI Apps in 2026 (Not the Models, the Apps Around Them) Incident Report: May 19, 2026- GCP Account Suspension Counting to 3 with a new builder processing 50M+ monthly builds Railway iOS preview now available via TestFlight Kill your onboarding: selling to 10,000+ new users a day Your AI wants to nuke your database. Guardrails fix that. Better Rails for Agents: A New Remote MCP and Railway Agent in the CLI Moving Railway's Frontend Off Next.js One command deploys, there's a Stripe APP for that From registrar to deployed: buying a domain inside Railway A letter to open source builders who deserve more Networking is a black box, we used eBPF to open it Heroku Walked So Railway Can Run Security Features Your Security Team Will Love Railway Runs Open Source, Now We're Funding It Railway raises $100M Series B to unburden the builders
Cron Jobs with Django and GitHub Actions
Faraz Patankar · 2023-03-22 · via Railway Blog

Update (31/08/23) — Cron Jobs now available on Railway

Railway now supports Cron Jobs natively. It may be a better fit for you than what’s written here. Check out https://docs.railway.com/cron-jobs for details!


Introduction

We’ve been asked a number of times how to orchestrate a cron job on Railway. Today we’re going to show you how to create your first Django cron using GitHub Actions.

This may come in handy if you’re looking to add a cron to a new or existing Railway project and will make it possible to run any Django task on a schedule on Railway.

Let’s get into it!

The GitHub Action

For those of you who are here to grab the example code, here’s the entire YAML needed to create a GitHub Action to run your Django tasks on a cron:

name: My Command

on:
  schedule:
    - cron: '*/4 * * * *'

jobs:
  build:
    name: Run crons
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3

      - uses: actions/setup-node@v3
        with:
          node-version: 16

      - name: Install Railway
        run: npm i -g @railway/cli

      - name: Install Python packages
        run: railway run --service {{SERVICE_ID}} pip install -r requirements.txt
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

      - name: My Command
        run: railway run --service {{SERVICE_ID}} python manage.py my_command
        env:
          RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

If you care to understand a bit more about how this works, please read on.

The Schedule

In the snippet below, we’re telling GitHub to run this Action every 4 minutes.

on:
  schedule:
    - cron: '*/4 * * * *'

Of course, you may use any cron expression you like to run your Action at your preferred interval. We recommend checking out CrontabGuru, which is a handy service to test out your cron expressions before adding them to your Action.

The Railway CLI

Next, we’ll install the Railway CLI which will allow us to interact with our Railway project from within the GitHub Action. You can read the docs to learn more about the CLI.

name: Install Railway
  run: npm i -g @railway/cli

Now that the Railway CLI is installed, we’ll run the task.

Running the Task

In the snippet below, we’ll invoke our my_command management command on our service using the Railway CLI. If you don’t have a RAILWAY_TOKEN secret, note that this can be generated by creating a Project Token for your project.

name: My Command
  run: railway run --service {{SERVICE_ID}} python manage.py my_command
  env:
    RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }}

Success! We’ve now run the task and started the cron!

Closing

In a few simple steps, we’ve made it possible to execute any Django task at a specific interval on our Railway projects and services.

We’d like to give a shoutout to Dan Rowden for sharing this GitHub Action which was written for a new project called InstantDM.

Additionally, if someone in the community would like re-work this GitHub Action to run rake tasks for Ruby on Rails — reach out and let us know! We’d love to help you get it working.