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

推荐订阅源

WordPress大学
WordPress大学
Vercel News
Vercel News
博客园_首页
Y
Y Combinator Blog
美团技术团队
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
阮一峰的网络日志
阮一峰的网络日志
aimingoo的专栏
aimingoo的专栏
H
Hackread – Cybersecurity News, Data Breaches, AI and More
MyScale Blog
MyScale Blog
GbyAI
GbyAI
人人都是产品经理
人人都是产品经理
T
Tailwind CSS Blog
MongoDB | Blog
MongoDB | Blog
D
DataBreaches.Net
博客园 - Franky
Engineering at Meta
Engineering at Meta
量子位
The GitHub Blog
The GitHub Blog
F
Fortinet All Blogs
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell
N
Netflix TechBlog - Medium

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 on Railway
Faraz Patankar · 2022-08-18 · 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!


Recently, we’ve had a few users ask us how they can go about deploying their cron jobs on Railway. While we don’t have first-party support for cron jobs, it is very easy to deploy them using language-level libraries.

This should be possible with all the languages we support. In this post, we will take JavaScript as an example and use the node-cron library to deploy a simple cron service on Railway.


Scaffolding our cron service

At Railway, we treat a cron job just as we would anything else you deploy on our platform. Whether it is a web application, an API, or a cron job, for us, they’re all just services within a project.

So let’s go ahead and scaffold a brand new TypeScript package using DTS.

npx dts-cli create cron-service

Once the setup is complete, we can cd into cron-service and add the node-cron package.

yarn add node-cron
yarn add -D @types/node-cron

Adding a cron job

Next, we can replace the existing code in src/index.ts with a basic cron job.

import cron from 'node-cron';

cron.schedule(`*/1 * * * *`, async () => {
  console.log('running your task...');
});

The code above will simply log running your task... after every single minute as that’s what we have set the cron schedule as.

Before we run this, we will make one minor change to the scripts inside our package.json file which will help us when we deploy our service on Railway.

{
  ...
	"scripts": {
    ...
    "start": "node dist/index.js"
	}
}

In the snippet above, we update the start script to use the built code from our dist directory. This will ensure the correct command is run when we deploy our service on Railway.

Running our cron job

To run our cron job, we simply build and run our code.

yarn build
yarn start
Demoing the cron service
Demoing the cron service

As you can see in the demo above, our message is logged to the console once every minute. In the next section, we will deploy this service to Railway.

Deploying to Railway

We can deploy our new cron service to Railway by either adding it to an existing project or creating a new project. In this example, I will use the Railway CLI to create a new project and deploy the service to that project.

Creating a new project on Railway
Creating a new project on Railway

Once our project is created, we can simply run railway up and our code will automatically be deployed to our project.

A demo of our cron service running on Railway
A demo of our cron service running on Railway

As you can see in the screenshot above, our cron job is run every minute as specified in our code. Everything was automatically built and deployed with no additional configuration needed.

Demo + Template

You can click here a live demo of the project we just deployed or click the button below to deploy your own in just one click!

Deploy on Railway

Closing

We hope this post helps anyone looking to deploy cron jobs on Railway and would love for people to contribute similar tutorials in other languages and frameworks. Feel free to reach out to us on Discord if you’re interested.