The other week I learnt a valuable lesson about pkill
, namely that it will match like a greedy little bastard unless instructed not to, which may have unintended consequences…
To illustrate, consider these two images:
Image may be NSFW.
Clik here to view.
So what happens is I start two processes, foo
and foobar
(which are simple shell scripts running sleep 1h
),
execute pkill foo
, and both foo
and foobar
dies.
Image may be NSFW.
Clik here to view.
Adding -x
(or --exact
) to the pkill command will ensure that only foo
gets killed.
If you want to go overnuking everything, regular pkill
will serve you well, but if you are looking for a scalpel, then -x
is most definitively what you want.
:wq