Task Scheduler Running Multiple Instances on Windows Server: Python Script Execution

Abstract: Prevent multiple instances of a Python script running via Windows Task Scheduler by setting the concurrency option to Do not start a new instance.

Created: 2026-08-02 by

Prevent multiple instances of a Python script running via Windows Task Scheduler by configuring the task properties to prohibit concurrent execution. Set the "Allow running if already running" option to "Do not allow new instance." This ensures that if a previous run is still active, the scheduler skips the new trigger, eliminating duplicate processes without requiring complex scripting or external locks.

The Root Cause: Concurrent Execution

When a scheduled task executes a Python script through Git Bash (typically using bash.exe), the Windows Task Scheduler treats each trigger as an independent event. If your script takes longer than the interval between triggers—for example, a one-minute trigger firing while the previous minute’s job is still processing—the scheduler may launch a second instance. This results in race conditions, corrupted data files, or resource exhaustion on the server. The default behavior for many tasks allows these instances to run simultaneously unless explicitly restricted. This is particularly common with scripts that involve file I/O, network requests, or heavy computation. Without proper safeguards, you end up with multiple python.exe or bash.exe processes consuming CPU and memory unnecessarily. To resolve this, we must adjust the task configuration rather than modifying the script itself.

Configuring Task Properties

The most reliable solution lies within the Windows Task Scheduler interface. You need to modify the specific task responsible for executing your points.sh script. Follow these steps to prevent overlapping runs:
  1. Open Task Scheduler: Press Win + R, type taskschd.msc, and hit Enter.
  2. Locate Your Task: Navigate to the folder containing your scheduled task. It might be under "Task Scheduler Library" or a custom folder you created.
  3. Edit Properties: Right-click the task and select Properties. Do not use the "Edit..." button in the action pane; use the main context menu to access all settings.
  4. Settings Tab: Click on the Settings tab at the top of the window.
  5. Concurrency Setting: Find the section labeled "Allow the task to be run if the task is already running."
By default, this dropdown is often set to "Do not start a new instance," which is what you want. However, if it is set to "Run new instance in parallel" or "Queue a new instance," change it immediately.

Choosing the Right Concurrency Option

There are three primary options here, and understanding them is critical:
  • Do not start a new instance: This is the correct setting for preventing duplicates. If the task is already running when the next trigger fires, the scheduler ignores the new trigger. The next opportunity will be the following trigger cycle.
  • Run new instance in parallel: This allows multiple copies of the script to run simultaneously. Avoid this unless your script is designed to handle multi-threading safely and independently.
  • Queue a new instance: This places the new run in a queue behind the current one. Once the first instance finishes, the second starts. While this prevents overlap, it can lead to a backlog if tasks consistently take longer than the trigger interval.
For a simple Python script executed every minute, "Do not start a new instance" is the safest choice. It ensures that only one process exists at any given time. If you choose "Queue," be aware that missed triggers will stack up, potentially causing a surge of executions later.

Verifying Git Bash Execution

Since you are using Git Bash to execute points.sh, ensure that the command line arguments are correctly passed. Often, users configure the task to run bash.exe with arguments like --login -c "./points.sh". If the task is misconfigured, it might spawn a shell that hangs, keeping the process alive longer than necessary. Check the "Actions" tab of your task properties. Ensure the program/script field points to C:\Program Files\Git\bin\bash.exe (or your local Git installation path). In the "Add arguments" field, verify that you are invoking the script correctly. For example:
--login -c "cd /path/to/script && ./points.sh"
Using absolute paths within the script or changing directories explicitly helps avoid issues where the working directory is ambiguous. If the script fails silently, the bash shell might remain open waiting for input, which would block the task from completing and trigger the "already running" state indefinitely.

Monitoring and Troubleshooting

After applying the settings, monitor the task history. Open the "History" tab in the task properties to see recent events. Look for Event ID 106, which indicates the task started, and Event ID 200, which indicates it ended successfully. If you see multiple start events before an end event, the concurrency setting has not been applied correctly. If the issue persists, check if other tasks are launching the same script. Multiple tasks triggering the same executable can cause conflicts even if individual task settings are correct. Additionally, review your Python script for infinite loops or unhandled exceptions that might prevent graceful termination. A hanging script will hold the lock, causing subsequent triggers to be skipped, which might look like the fix is working but actually indicates a deeper problem in the code. For more details on general scheduling issues, refer to our guide on Python Script Not Running with Task Scheduler: How to Fix. Another useful resource is Scheduling a Task to Start a Batch File with Windows Task Scheduler, which covers similar foundational concepts for batch-based automation.

Frequently Asked Questions

How do I force stop a stuck Python script instance?

Use the Task Manager to find the specific python.exe process associated with your script and end it manually. Alternatively, use PowerShell with Stop-Process -Name python -IncludeUserName to target the user running the task, avoiding accidental termination of other Python applications.

What happens if I select 'Queue a new instance' instead?

The scheduler will wait for the current instance to finish before starting the next one. This creates a backlog if tasks are slow, potentially leading to a burst of executions once the system catches up, which can overwhelm resources.

Can I add a lock file inside my Python script?

Yes, creating a temporary lock file (e.g., .lock) at the start of the script and deleting it at the end is a valid software-level solution. However, configuring Task Scheduler is simpler and more robust because it operates at the OS level, preventing the script from even launching if a conflict exists.

Why does my task still run twice despite the setting?

This usually occurs if there are two separate tasks configured to run the same script, or if the task is triggered by both a schedule and an event log. Check the "Triggers" tab to ensure only one active trigger exists, and verify no other tasks share the same executable path.

Is it safe to use taskkill to remove duplicates?

No, using taskkill /f /im python.exe is dangerous because it terminates ALL Python processes on the server, including unrelated services or user applications. Always target specific process IDs or use Task Manager to kill only the relevant instance.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More