forked from WuJunJu/cdnkill
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_python_restart.bat
More file actions
31 lines (26 loc) · 1.33 KB
/
Copy pathrun_python_restart.bat
File metadata and controls
31 lines (26 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
@echo off
chcp 65001 >nul 2>&1 :: Set UTF-8 encoding to avoid garbled characters
title Python Script Daemon :: Set window title
:: ====================== CONFIGURATION (MODIFY THESE) ======================
set "PYTHON_PATH=python" :: If python not in PATH, use absolute path (e.g., C:\Python310\python.exe)
set "PYTHON_SCRIPT=boom.py" :: Your .py file path (relative/absolute)
set "RESTART_DELAY=3" :: Seconds to delay before restart (0 = immediate)
:: ==========================================================================
:: Infinite loop to keep the script running
:loop
:: Print current time and running info
echo.
echo ==================== [%date% %time%] ====================
echo Starting Python script: %PYTHON_SCRIPT%
echo --------------------------------------------------------
:: Run the Python script (continue loop even if it crashes)
%PYTHON_PATH% "%PYTHON_SCRIPT%"
:: Logic after script exits/crashes
echo.
echo ==================== [%date% %time%] ====================
echo WARNING: Python script exited/crashed!
echo Restarting in %RESTART_DELAY% seconds...
echo (Press Ctrl+C to stop the daemon process)
timeout /t %RESTART_DELAY% /nobreak >nul 2>&1 :: Delay before restart
:: Jump back to loop to restart the script
goto loop