Guide

How to keep a Python bot running 24/7 on Windows

Your trading bot, Discord bot or scraper works fine until it doesn't: it crashes at 3am, Windows restarts for an update, and you find out the next afternoon. Here are four ways to keep it up on your own PC, from free and fiddly to one click, current as of October 2026.

First: stop Windows from sleeping

No method below helps if the PC is asleep. Open Settings → System → Power, and set "When plugged in, put my device to sleep after" to Never. The screen can still turn off.

1. A restart loop (free, 2 minutes)

Make a file called run-bot.bat next to your bot:

@echo off
cd /d "%~dp0"
:loop
python bot.py
echo Bot stopped. Restarting in 5 seconds...
timeout /t 5 /nobreak >nul
goto loop

Double-click it and the bot starts again every time it exits. For Node, swap the python line for node bot.js.

Downsides: it lives in a console window you can close by accident, it doesn't start after a reboot, and if the bot crashes on startup it loops forever.

2. Task Scheduler (free, starts after a reboot)

  1. Open Task Scheduler and choose Create Task (not "Basic Task").
  2. On Triggers, add "At log on".
  3. On Actions, start your run-bot.bat.
  4. On Settings, tick "If the task fails, restart every 1 minute" and untick "Stop the task if it runs longer than".

Downsides: you can't see whether it's running without opening Task Scheduler, and there's no log unless your bot writes one.

3. A Windows service with NSSM (free, runs before you log in)

NSSM turns any program into a Windows service that restarts when it exits. From an admin PowerShell:

nssm install MyBot "C:\Path\To\python.exe" "C:\bots\mybot\bot.py"
nssm set MyBot AppDirectory "C:\bots\mybot"
nssm start MyBot

Downsides: services run in the background with no window, so debugging means reading log files, and services don't see your user's environment and files the same way your terminal does.

Get a phone alert when it crashes

Install the free ntfy app on your phone and subscribe to a topic name only you know. Then add one line to the restart loop, after the bot exits:

curl -s -d "My bot stopped, restarting" ntfy.sh/your-secret-topic

curl comes with Windows 10 and 11. A Discord webhook works the same way if you'd rather get the alert in a channel.

4. Helmdeck (one click, with a dashboard)

If you run more than one bot, the scripts above multiply fast. Helmdeck does all of it from one window:

from helmdeck_status import report, money
stat, trend = money(142.8)    # "+$142.80 today", shown in green
report("running", stat=stat, trend=trend, value=142.8)

Helmdeck is free for 3 builds. Restarts, schedules and phone alerts are part of Pro, which is $39 once.

Which one should you use?

Restart loopTask SchedulerNSSM serviceHelmdeck
Restarts after a crashYesYesYesYes
Starts after a rebootNoYesYesYes
Stops a crash loopNoNoThrottles itYes
See what's running at a glanceNoNoNoYes
Phone alertsWith curlWith curlWith extra setupBuilt in
CostFreeFreeFreeFree for 3, Pro $39 once

For a single bot, Task Scheduler plus an ntfy line is plenty. Once you have a few bots, or want to see them all from your phone, that's what Helmdeck is for.

Keep every bot running from one window

Free for 3 builds on Windows, Mac and Linux. No account needed.