I try to find a list of processes and kill them using verbose option, but not successful.
$ kill --verbose -9 $(ps -eo pid,cmd | grep cmd_name | grep -v grep | awk '{ print $1 }')
bash: kill: -verbose: invalid signal specification
Then I try to put '-9' in front.
$ kill -9 --verbose $(ps -eo pid,cmd | grep cmd_name | grep -v grep | awk '{ print $1 }')
bash: kill: --verbose: arguments must be process or job IDs
If I don't use verbose, it seems working fine. But I like to use verbose here if possible.
BTW, I am using RHEL 8 and this is part of the man page.
--verbose
Print PID(s) that will be signaled with kill
along with the signal.
There's a
pkillcommand that kills processes by name. Use that. All thisps | grep | grep -v grepstuff is so ancient.(I'm not shaming you. I want to alert people who find this question on Google.)
It doesn't have an option to both print and kill at the same time. If you want to also print the PIDs being killed you could leverage its companion command
pgrep: