Skip to content

Instantly share code, notes, and snippets.

@amoilanen
Last active August 19, 2018 15:01
Show Gist options
  • Save amoilanen/22bfa15b167c37a94570bf1a5bafd092 to your computer and use it in GitHub Desktop.
Save amoilanen/22bfa15b167c37a94570bf1a5bafd092 to your computer and use it in GitHub Desktop.
Better 'killall' command in Bash, analogous to 'kill -9' usage: 'terminate.sh java'
#!/bin/bash
pids_to_kill=$(ps aux|grep $1|grep -v grep|grep -v terminate.sh |awk '{print $2}')
[[ ! -z $pids_to_kill ]] && kill -9 $pids_to_kill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment