/replit-tutorials

How to run background jobs in Replit

Learn simple methods to run background jobs in Replit, automate tasks, and keep processes running reliably in your projects.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to run background jobs in Replit

The short version: Replit does not support true background jobs that keep running after your Repl goes to sleep. If you need something to run continuously, you must keep the Repl awake with an external pinger or run your job inside the main process of a “Deploy → Always On” plan. For scheduled tasks (like cron jobs), you implement a scheduler inside your running code, because Replit does not have a built‑in cron system.

 

What “background jobs” realistically mean in Replit

 

On your laptop, you might have a daemon process, a cron job, or a worker that keeps running even after you close your terminal. Replit is different. A Repl goes to sleep when nobody is interacting with it unless it’s deployed as an Always On service (paid feature). When it sleeps, all background work stops.

The safe mindset is this: a Repl can only run long-lived background tasks if the Repl itself stays awake. And that only happens if:

  • It’s deployed as Always On through Replit Deployments
  • Or an external uptime service pings your webserver endpoint (unofficial workaround, not guaranteed forever)

 

Way #1 — Run background jobs inside the main server process

 

This is the most common and reliable approach. Instead of trying to spin off a second script in the background, you run a scheduler inside your web server code. The server runs continuously (if Always On), and your scheduled job runs on intervals.

Example with Node.js using setInterval:

import express from "express";
const app = express();

// Your normal endpoint
app.get("/", (req, res) => {
  res.send("Server running!");
});

// Background job: runs every 60 seconds
setInterval(() => {
  console.log("Background job executed!"); 
  // Put your logic here: cleanup, API fetch, etc.
}, 60 * 1000);

// Start the server
app.listen(3000, () => {
  console.log("Server started on port 3000");
});

This works because the job is part of the running application. As long as the server stays alive (Always On), the job keeps running.

 

Way #2 — Use a dedicated worker Repl (only if Always On)

 

Sometimes you want a clean separation: one Repl for your API, one Repl for background tasks. In that case, you run a single script with an infinite loop or a scheduler.

Example using Python with schedule:

import schedule
import time

def job():
    print("Background job executed!") 
    # Put your logic here

schedule.every(1).minutes.do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

This only works reliably if the worker Repl is deployed as Always On. Otherwise, it will stop when the Repl sleeps.

 

What does NOT work reliably

 

  • Running a script in the Shell and expecting it to stick — it dies when you close the tab.
  • Using nohup or tmux — Replit containers shut down when idle.
  • Expecting cron jobs — Replit does not have a cron system.
  • Creating child processes hoping they survive — they die with the main process.

 

What to use if you can’t afford Always On

 

If Always On isn’t an option, the workaround is to expose a simple HTTP endpoint and use an external uptime monitor to ping your Repl every few minutes. This prevents the container from sleeping, so your in-process scheduler works. Not officially supported, but widely used in practice.

Your code still runs the same as in earlier examples. The difference is that an external service keeps your Repl awake.

 

Summary

 

  • Replit has no true background processes unless the Repl stays awake.
  • Use Always On or an external pinger to keep the Repl alive.
  • Run background jobs inside your main app using setInterval, schedule, or similar tools.
  • Child processes, shell "&" jobs, cron, nohup, tmux — none of these survive container sleep.

If you treat Replit like a cloud runtime instead of a laptop, background jobs become straightforward: a continuously running deployment, with your scheduler living inside the app itself.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022