Skip to content

Instantly share code, notes, and snippets.

@spion
Last active November 28, 2021 15:49
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spion/5213058 to your computer and use it in GitHub Desktop.
Save spion/5213058 to your computer and use it in GitHub Desktop.
killgrep and psgrep
#!/bin/bash
# Put me in /usr/local/bin/killgrep
ps aux | egrep $1 | egrep -v '(killgrep)|(egrep)' | awk '{print $2}' | xargs kill -9
#!/bin/bash
# Put me in /usr/local/bin/psgrep
ps aux | egrep $1 | egrep -v '(psgrep)|(egrep)'
@gdamjan
Copy link

gdamjan commented Mar 21, 2013

не е ова исто со killall?

@spion
Copy link
Author

spion commented Jun 27, 2013

Не е исто бидејќи killall работи само со името на binary-то, не и со аргументите (значи не работи за python/node скрипти).

@JohnRobson
Copy link

Check this:
$ pgrep name
$ pkill name
$ pkill --signal 15 name

@spion
Copy link
Author

spion commented Dec 3, 2018

Doesn't work with scripts, they're arguments to the command so pgrep doesn't get them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment