Finding and Killing Linux pids
Someone left a program running for days, and its killing the server and they're out for a long weekend. what can you do?
To find all the processes running by a user
ps -fu jbrooks
to see all processes running in full view as opposed to list view
ps -ef
Nice list of how to use ps
https://www.geeksforgeeks.org/ps-command-in-linux-with-examples/
Once you have found the process[es]
you can stop them from running with the kill command
kill -s 9 11677
These show more, in increasing depth.
- https://www.howtoforge.com/linux-kill-command/
- https://www.unix.com/man-page/Linux/1/kill/
- https://www.man7.org/linux/man-pages/man7/signal.7.html
I'm going to throw in xargs here too.
This is great for killing a list of pids. It takes the output of a command and does a "crosstab" kind of transform to allow a new command to iterate over the list as inputs
ps --ppid 11438|cut -d' ' -f 2 |xargs kill
finally, pkill takes the parent pid and kills the children leaving no zombies. The parent pid is the second pid number, the PPID
UID PID PPID C STIME TTY TIME CMD
jbrooks+ 23746 1 0 Jan30 ? 00:00:02 /usr/bin/bash ./date_db2mon.sh
jbrooks+ 101236 1 0 2022 ? 00:00:44 /usr/bin/bash ./date_exp_edw.sh 2
jbrooks+ 137688 137671 0 11:25 ? 00:00:00 sshd: jbrooks@pts/5
jbrooks+ 137689 137688 0 11:25 pts/5 00:00:00 -bash
jbrooks+ 162053 161508 0 13:49 ? 00:00:00 sshd: jbrooks@pts/2
pkill -P 137671
Comments
Post a Comment