Kill a Process in Linux from command line using kill command:
kill process by name:
kill $(ps aux | grep 'process_name' | awk '{print $2}')
kill process by ID
kill -9 PID
Kill all descendant/recursively processes
The easy way to do this in a shell script is using pkill command:
pkill -TERM -P 123456
where PPID / parent processes PID is 123456
if pkill isn’t available, try this way:
kill $(ps -o pid= --ppid $$)
or using PGID / group number of process group you want to kill
kill -TERM -- -123456
where PGID is 123456
Leave a Reply
Your email address will not be published. Required fields are marked *