Skip to main content
RapidDev - Software Development Agency
replit-tutorial

How to run scheduled jobs in Replit

Replit offers a Scheduled deployment type that runs your code on a recurring schedule using natural language input like 'every day at 9 AM.' It costs $1 per month plus compute time at $0.000061 per second. You configure the schedule in the Deployments pane, set your run command in .replit, and Replit handles the rest with zero cron syntax required.

What you'll learn

  • Create a script designed for periodic execution
  • Configure a Scheduled deployment with natural language scheduling
  • Set up Secrets for API keys used in scheduled tasks
  • Monitor scheduled job execution through the Logs tab
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner8 min read10-15 minutesReplit Core ($25/mo) and Pro ($100/mo) plans. Scheduled deployments are not available on the free Starter plan. Works with Python, Node.js, and any language.March 2026RapidDev Engineering Team
TL;DR

Replit offers a Scheduled deployment type that runs your code on a recurring schedule using natural language input like 'every day at 9 AM.' It costs $1 per month plus compute time at $0.000061 per second. You configure the schedule in the Deployments pane, set your run command in .replit, and Replit handles the rest with zero cron syntax required.

Run Scheduled Jobs in Replit Without Writing Cron Syntax

This tutorial shows you how to set up periodic tasks in Replit using the Scheduled deployment type. Instead of writing traditional cron expressions, you describe your schedule in plain English and Replit translates it into a recurring job. Common use cases include sending daily email digests, refreshing API data every hour, running nightly database cleanup scripts, and posting scheduled social media updates. This guide covers the full setup from writing your script to deploying it on a schedule.

Prerequisites

  • A Replit account on the Core ($25/mo) or Pro ($100/mo) plan
  • A Replit App with a working script you want to run periodically
  • Basic familiarity with the Replit workspace (Shell, file tree, Run button)
  • Any API keys stored in Tools → Secrets before starting

Step-by-step guide

1

Write a self-contained script for scheduled execution

Scheduled deployments run your script once per trigger, then stop. Your code must complete its work and exit cleanly — it should not start a web server or run an infinite loop. Create a Python or Node.js script that performs a single task such as fetching data from an API, sending a notification, or cleaning up a database. The script should log its progress so you can verify execution in the Logs tab later.

typescript
1# scheduled_task.py
2import os
3import datetime
4import json
5
6def main():
7 print(f"[{datetime.datetime.now().isoformat()}] Scheduled task started")
8
9 api_key = os.getenv("API_KEY")
10 if not api_key:
11 print("ERROR: API_KEY secret not found")
12 return
13
14 # Your periodic task logic here
15 print("Performing scheduled work...")
16 print(f"[{datetime.datetime.now().isoformat()}] Scheduled task completed")
17
18if __name__ == "__main__":
19 main()

Expected result: Running the script manually with the Run button prints timestamped start and completion messages to the Console.

2

Add required Secrets for your scheduled task

If your scheduled script uses API keys or credentials, add them to the Secrets tool before deploying. Open the Tools dock on the left sidebar and click Secrets. Add each key-value pair under the App Secrets tab. Important: workspace Secrets do not automatically carry over to deployments. You will need to add them again in the deployment configuration in a later step. This is the number one cause of scheduled task failures.

Expected result: Your Secrets appear in the App Secrets list and are accessible via os.getenv() or process.env when you run the script.

3

Configure the .replit file for scheduled deployment

Open your .replit file (enable Show hidden files in the file tree menu if needed) and set the deployment run command to execute your scheduled script. The deployment section tells Replit what command to run each time the schedule triggers. Make sure the run command points to your script file and includes any necessary setup steps like installing dependencies.

typescript
1# .replit
2entrypoint = "scheduled_task.py"
3
4run = "python scheduled_task.py"
5
6[deployment]
7run = ["sh", "-c", "python scheduled_task.py"]
8build = ["sh", "-c", "pip install -r requirements.txt"]
9deploymentTarget = "cloudrun"

Expected result: The .replit file is saved with a deployment run command that executes your scheduled script.

4

Create a Scheduled deployment

Click the Deployments tab in the top right of your workspace. Select Scheduled as the deployment type. In the schedule field, type your desired frequency in natural language — for example 'every day at 9 AM UTC,' 'every Monday at 6 PM,' or 'every 2 hours.' Replit interprets this and shows you the parsed schedule for confirmation. Review the configuration, make sure your Secrets are added in the deployment settings, then click Deploy.

Expected result: The deployment starts provisioning. After 30-60 seconds, the status changes to Active and shows the next scheduled run time.

5

Add Secrets to the deployment configuration

After creating the deployment, go to the deployment settings and add all Secrets your script needs. This is a separate step from workspace Secrets. Click on the deployment, find the Secrets or environment variables section, and re-enter each key-value pair. Without this step, your script will fail with undefined environment variable errors at runtime even though it works perfectly in the workspace.

Expected result: All required Secrets appear in the deployment configuration. The next scheduled run will have access to these values.

6

Monitor execution in the Logs tab

After your first scheduled run triggers, check the Logs tab in the Deployments pane to verify everything worked. The Logs tab shows stdout and stderr output from each execution, including your print statements and any error messages. Look for your timestamped start and completion messages. If you see errors about missing environment variables or modules, fix the deployment configuration and redeploy.

Expected result: The Logs tab shows your script output with start and completion timestamps, confirming the scheduled task ran successfully.

Complete working example

scheduled_task.py
1# scheduled_task.py A complete scheduled job for Replit
2import os
3import datetime
4import json
5import urllib.request
6import urllib.error
7
8def log(message):
9 """Print a timestamped log message."""
10 timestamp = datetime.datetime.now().isoformat()
11 print(f"[{timestamp}] {message}")
12
13def send_slack_notification(webhook_url, message):
14 """Send a message to a Slack channel via webhook."""
15 payload = json.dumps({"text": message}).encode("utf-8")
16 req = urllib.request.Request(
17 webhook_url,
18 data=payload,
19 headers={"Content-Type": "application/json"}
20 )
21 urllib.request.urlopen(req)
22
23def main():
24 log("Scheduled task started")
25
26 # Load secrets from environment
27 api_key = os.getenv("API_KEY")
28 slack_webhook = os.getenv("SLACK_WEBHOOK_URL")
29
30 if not api_key:
31 log("ERROR: API_KEY secret is missing. Add it in Deployments > Secrets.")
32 return
33
34 try:
35 # Example: fetch data from an API
36 url = f"https://api.example.com/data?key={api_key}"
37 req = urllib.request.Request(url)
38 with urllib.request.urlopen(req) as response:
39 data = json.loads(response.read().decode())
40 log(f"Fetched {len(data)} records")
41
42 # Process the data
43 processed_count = 0
44 for item in data:
45 # Your processing logic here
46 processed_count += 1
47
48 log(f"Processed {processed_count} records")
49
50 # Send success notification
51 if slack_webhook:
52 send_slack_notification(
53 slack_webhook,
54 f"Scheduled task completed: {processed_count} records processed"
55 )
56
57 except urllib.error.URLError as e:
58 log(f"ERROR: API request failed — {e}")
59 if slack_webhook:
60 send_slack_notification(slack_webhook, f"Scheduled task FAILED: {e}")
61 except Exception as e:
62 log(f"ERROR: Unexpected failure — {e}")
63 raise
64
65 log("Scheduled task completed")
66
67if __name__ == "__main__":
68 main()

Common mistakes when running scheduled jobs in Replit

Why it's a problem: Starting a web server in a scheduled script instead of running a task and exiting

How to avoid: Scheduled deployments expect your script to complete and exit. Remove any app.listen() or infinite loops. Write a main() function that does its work and returns.

Why it's a problem: Only adding Secrets in the workspace and not in the deployment configuration

How to avoid: Workspace Secrets do not carry to deployments automatically. After deploying, go to the deployment settings and add all required Secrets again.

Why it's a problem: Not specifying a timezone in the schedule, causing jobs to run at unexpected times

How to avoid: Always include a timezone like UTC in your natural language schedule: 'every day at 9 AM UTC' instead of just 'every day at 9 AM.'

Why it's a problem: Using REPLIT_DEV_DOMAIN in a scheduled script, which is only available in the workspace

How to avoid: REPLIT_DEV_DOMAIN does not exist in deployments. Use REPLIT_DOMAINS instead, or hardcode your production URL.

Best practices

  • Always specify UTC in your schedule description to avoid timezone confusion across team members
  • Keep scheduled scripts short and focused — one task per script, not a monolith
  • Add error handling and notification logic since scheduled deployments do not alert on failure
  • Log timestamps at the start and end of every run so you can verify execution timing in the Logs tab
  • Add Secrets to both the workspace and the deployment configuration — they are separate
  • Use the build command for dependency installation so it only runs once during deployment, not on every scheduled trigger
  • Set budget controls in your account settings to avoid unexpected compute charges from long-running scripts
  • Test your script manually with the Run button before creating the scheduled deployment

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to run a Python script on a schedule in Replit. The script fetches data from an API and sends a Slack notification. How do I set up a Scheduled deployment with natural language scheduling, configure Secrets for the API key, and monitor execution logs?

Replit Prompt

Create a scheduled task that runs every day at 9 AM UTC. The script should fetch data from an external API using the API_KEY secret, process the results, and send a summary to Slack using the SLACK_WEBHOOK_URL secret. Make sure the script exits cleanly after completing.

Frequently asked questions

Scheduled deployments cost $1 per month base fee plus $0.000061 per second of compute time. A script that runs for 30 seconds daily costs roughly $1.05 per month total. Build time is free — only runtime is billed.

No. Replit's Scheduled deployment type only accepts natural language descriptions like 'every day at 9 AM UTC' or 'every 2 hours.' There is no cron expression input. Replit parses your description and shows the interpreted schedule for confirmation.

The script stops and the error is logged in the Deployments Logs tab. Replit does not send failure notifications automatically. Add error handling with notification logic (email, Slack webhook) to your script to get alerted when something goes wrong.

Yes. You can schedule tasks as frequently as every minute by typing 'every minute' in the schedule field. Be mindful of compute costs — a script running every minute for 30 seconds costs roughly $28 per month in compute alone.

Yes, Secrets work in Scheduled, Autoscale, and Reserved VM deployments. They do NOT work in Static deployments. Remember to add Secrets separately in the deployment configuration — workspace Secrets are not automatically included.

You can test your script manually by pressing the Run button in the workspace. This runs the same code locally. However, there is no 'run now' button for the deployed scheduled task — you must wait for the next scheduled trigger or redeploy.

For multi-step workflows, conditional logic, and integrations across services, the RapidDev engineering team can help you design a production-grade automation pipeline that goes beyond single-script scheduling.

No. The compute instance spins up when the schedule triggers, runs your script, and shuts down when the script exits. You only pay for the seconds your script is actually running. This is not suitable for always-on processes — use a Reserved VM deployment for that.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.