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

推荐订阅源

Y
Y Combinator Blog
IT之家
IT之家
博客园_首页
人人都是产品经理
人人都是产品经理
博客园 - Franky
I
InfoQ
Recent Announcements
Recent Announcements
P
Proofpoint News Feed
H
Hackread – Cybersecurity News, Data Breaches, AI and More
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
月光博客
月光博客
Microsoft Security Blog
Microsoft Security Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog RSS Feed
MongoDB | Blog
MongoDB | Blog
雷峰网
雷峰网
博客园 - 聂微东
N
Netflix TechBlog - Medium
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
The GitHub Blog
The GitHub Blog
D
Docker

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.