DEV Community

Discussion on: How to keep a process running even after closing SSH connection?

Collapse
 
krishnanunnir profile image
Krishnanunni R

If I may ask how do you handle killing the process?

Collapse
 
aderchox profile image
aderchox

Here's my note on this for you:

===== Listing Processes =====
List processes owned by the current user (sorted by PID, from PID 1 to higher/user-level PIDs)
ps
List all processes, including system processes
ps ax
List all active processes, including system processes, with extra information like RAM/CPU usage, owner user, etc.
ps aux
Human-readable shiny process list, with features like search, filtering, tree structure, realtime resources usage monitor, etc.
htop

===== Killing Processes (kill vs. killall vs. pkill) =====
Kill a process by its id
kill <process_id>
Or use killall with the process name (Can be risky if multiple processes share the same name)
killall node
Or use pkill with the process name or other attributes (The most versatile of the three commands, allows terminating processes by name, exact match, or pattern matching using regular expressions) (Can be risky if the pattern matches unintended processes)
pkill

Killing without mercy
kill -9 <process_id>
Killing by giving the stuck process a chance to clean up before dying (RECOMMENDED)
kill -15 <process_id>