[CALUG] how to kill a process tree in PS
Bryan Smith
b.j.smith at ieee.org
Wed Nov 1 23:00:20 EDT 2017
On Fri, Oct 27, 2017 at 11:57 AM, Walt Smith <waltechmail at yahoo.com> wrote:
> The question is this:
> how can I kill a tree of processes? I find the man page simply
> comfusing.
It's largely confusing as [child] processes, parent processes, etc...
are somewhat independent, but somewhat not as well (long story).
There is not basic, POSIX** (UNIX/Linux) "magic bullet."
On Mon, Oct 30, 2017 at 3:19 PM, Tim Spangler <tspang at jefnet.com> wrote:
> Unless centOS does something I don't know about, I imagine the easiest way would be
> to ps -ef and grep for the parent pid, then pipe it to awk and use xargs to kill all
> the processes. If the parent process is already dead, the parent process should
> revent to 1, in which case you'd need to grep for a string in your process, like kppp"
Definitely want to try to kill (SIGTERM, -15) all of the child processes first.
- bjs
**P.S. Now cgroups do offer a way to not only pin resources, but
contain processes. If you are concerned with killing all processes,
consider investigating setting up a cgroup (you can still tell the
cgroup to use all resources), which will allow you to also nuke the
cgroup (removing all resources -- causing everything to die), which is
all done at the kernel-level.
SIDE NOTE: systemd sets up a dedicated cgroup for each service, which
is how/why systemd can guarantee processes are always killed on
shutdown (when the cgroup is removed, which ensures such if other
attempts fail).
More information about the CALUG
mailing list