How to see what Python scripts are currently running on your computer
The simplest way to check if a Python script is running in the background depends on your operating system. On Windows, you open Task Manager and look for python.exe or pythonw.exe in the Processes tab. On Mac or Linux, you open a terminal and type ps aux | grep python to see all active Python processes with their details.
Both methods show you the script name, how much memory it is using, and its process ID — a number that identifies that specific running instance. If you see multiple Python processes, the command line or details column tells you which script each one is running.
Understanding what you are looking at matters because a Python script running in the background behaves differently from one you launched in a terminal window. A background script keeps running even after you close the terminal, which is useful for tasks like monitoring a folder or sending scheduled emails, but it also means you cannot see its output unless you set up logging.
Key Takeaways
- On Windows, open Task Manager (Ctrl+Shift+Esc), go to the Processes tab, and search for python.exe or pythonw.exe to see running Python scripts.
- On Mac or Linux, open a terminal and run ps aux | grep python to list all Python processes with their memory use and process ID.
- The process ID (PID) is a unique number that identifies each running script, and you can use it to stop a script with the kill command.
- A script running with pythonw.exe on Windows or launched with an ampersand (&) on Mac or Linux will continue running even after you close the terminal.
- If a Python script is using a lot of memory or CPU, you can stop it from Task Manager on Windows or with the kill command on Mac or Linux.
Checking running scripts on Windows using Task Manager
Open Task Manager by pressing Ctrl+Shift+Esc or right-clicking the taskbar and selecting Task Manager. Click the Processes tab at the top. Look for entries labeled python.exe or pythonw.exe — these are Python processes. The difference matters: python.exe shows a console window when it runs, while pythonw.exe runs silently in the background.
Click on any Python process to see more details. The command line column (you may need to scroll right or resize columns) shows the full path to the script being run. If you see something like C:\Users\YourName\Documents\monitor.py, that is the script name. The Memory column shows how much RAM that process is using right now.
If you want to stop a running script, right-click it and select End Task. The script will stop immediately, though any unsaved data it was working with will be lost. This is useful if a script is frozen or using too much memory, but be careful not to stop a script that is in the middle of important work.
Checking running scripts on Mac or Linux using the terminal
Open a terminal window and type ps aux | grep python then press Enter. You will see a list of all Python processes currently running. Each line shows the username, process ID (PID), CPU percentage, memory percentage, and the full command that started the script.
The output looks dense at first, but the last column is what you need: it shows the actual command. If you see python3 /home/user/backup.py, that tells you the script /home/user/backup.py is running. The PID (a number in the second column) is how you identify and control that specific process.
To stop a running script, type kill PID where PID is the number from the second column. For example, kill 12345 stops the process with ID 12345. If the script does not stop after a few seconds, you can force it with kill -9 PID, though this is more abrupt and should be a last resort.
Understanding what the output tells you
When you see a Python process listed, the information shown includes how much of your computer's resources it is using. The CPU percentage shows how much processing power it is taking right now — a script doing heavy calculations might show 80% or higher, while one that is mostly waiting for something might show 0% or 1%. The memory percentage shows how much of your total RAM the script is using.
The command line or full command tells you not just the script name, but also any arguments passed to it. A script might be run as python3 process.py --input data.csv --output results.txt, which tells you it is processing a file called data.csv and writing results to results.txt. This detail helps you understand what the script is actually doing.
If you see a Python process but do not recognize the script name, that is worth investigating. It could be a legitimate background task you set up and forgot about, or it could be something installed by another program. Search for the script name online or check your Documents and Downloads folders to figure out where it came from.
Finding scripts that are hidden or hard to spot
Some Python scripts are harder to find because they run under a different name or are started by another program. On Windows, if you see a process called python.exe but the command line is cut off, click on the process and look at the Details tab — it sometimes shows more information there. You can also right-click the column headers and add the Command Line column if it is not already visible.
On Mac or Linux, if ps aux | grep python shows too much output or includes the grep command itself, try pgrep -a python instead. This shows only the process ID and command for each Python process, which is cleaner. If you want to see only scripts running under your own user account, type ps aux | grep python | grep $USER.
Scripts started by system services or scheduled tasks (like cron jobs on Linux or Task Scheduler on Windows) will still show up in these lists, but they may be running under a different user account. On Windows, check the User column in Task Manager to see which account is running each process. On Linux, the first column of ps aux shows the username.
Stopping a script safely versus stopping it forcefully
If a script is running and you want to stop it, you have options. The gentle approach is to send it a signal that says "please stop" — on Mac or Linux, this is kill -TERM PID or just kill PID. The script receives this signal and can finish up any work it is doing before shutting down. If the script is written to handle this signal properly, it will close files and clean up before exiting.
The forceful approach is kill -9 PID on Mac or Linux, or End Task on Windows. This stops the script immediately without giving it a chance to clean up. Use this only if the gentle approach does not work or if the script is frozen and not responding. The risk is that the script might leave files in an incomplete state or leave resources locked.
On Windows, if you use End Task and the script restarts immediately, something else is launching it — possibly a scheduled task, a service, or another program. Check Task Scheduler (search for it in the Start menu) to see if there is a task running the script automatically. On Mac or Linux, check your crontab by typing crontab -l to see if a scheduled job is restarting it.
Monitoring a script over time
If you want to watch how a Python script behaves while it runs, you can use more detailed monitoring tools. On Windows, Resource Monitor (search for it in the Start menu) shows CPU and memory use for each process in real time, updated every second or so. On Mac, Activity Monitor (in Applications > Utilities) does the same thing. On Linux, top or htop (if installed) shows a live-updating list of processes sorted by resource use.
These tools help you spot problems: if a script is using 100% CPU constantly, it might be stuck in an infinite loop. If memory keeps climbing, it might have a memory leak. If it is using almost no resources, it might be waiting for something — a file to appear, a network response, or user input.
For longer-term monitoring, most Python scripts should write their own logs. A script that logs what it is doing makes it much easier to troubleshoot problems later. You can check the log file to see when the script started, what it did, and whether it finished successfully or hit an error.
Frequently Asked Questions
How do I know if a Python script is actually running or just frozen?
Check the CPU percentage in Task Manager or ps aux. If it is 0% or very low and has not changed for several minutes, the script is likely frozen or waiting. If the memory use keeps growing, it is probably running but stuck in a loop. Try stopping it and checking the script's log file (if it has one) to see where it got stuck.
Can I see what a background Python script is doing right now?
Not directly from Task Manager or ps — those tools only show that it is running. If the script writes to a log file, you can open that file and read it. Otherwise, you would need to modify the script to add logging, or run it in a terminal window instead of the background so you can see its output.
What does pythonw.exe do differently from python.exe?
pythonw.exe runs Python scripts without showing a console window, while python.exe shows a black command window. Both run the script the same way; pythonw.exe is just quieter. Scripts run with pythonw.exe still appear in Task Manager and can be stopped the same way.
If I close my terminal window, will the Python script keep running?
It depends on how you started it. If you typed the command normally and pressed Enter, closing the terminal stops the script. If you typed the command followed by an ampersand (&) on Mac or Linux, or if you used pythonw.exe on Windows, the script keeps running. You can still see it in Task Manager or ps aux even after the terminal closes.
Why is a Python script using so much memory?
The script might be loading a large file into memory, processing a lot of data, or it might have a memory leak where it keeps allocating memory without releasing it. Check the script's log file if it has one, or look at the command line to see what file it is processing. If memory use keeps climbing over time, the script probably has a bug.