Here is the scenario: you’ve started a process in Linux and it is currently running. But you need to close your computer or just the terminal. How are we going to achieve this? It is possible to close Mac Terminal Without Killing Running Processes in Linux. There are a couple of ways to do that, we will use TMUX.
sudo apt install tmux #for ubuntu and debian
tmux new -s your_session_name
A screen with green at its bottom is going to appear. Run your application here.
#Press KNTRL-b and then d
Step 5: Close Your Terminal.
Step 6: Display Your Running Sessions:
Step 7: Attach Your Running Session:
tmux attach-session -t your_session_name
How to Find and Kill a Running Python Script?
First, list all running Python3 processes. This will give you a Process ID (pid).
ps -ef | grep python3
After that, you can kill the running Python3 process with its PID number:
kill -9 PID_NUMBER
How to Kill all Running TMUX Sessions
#Identify the tmux sessions tmux list-sessions # kill all tmux sessions graciously tmux kill-server #kill all tmux sessions grossly pkill -f tmux #kill a specific tmux session tmux kill-session -t targetSession #kill all tmux sessions but the one you are in: tmux kill-session -a