0

I have a gitlab process running under the username gitlab-+. I would like to kill all processes from the user.

When I try:

pkill -9 -u gitlab-+

It comes back with invalid user name. I tried

pkill -9 -u gitlab* with the same result. How can I specify a wildcard in the `-u` argument for `pkill`
Luca
  • 10,458
  • 24
  • 107
  • 234

2 Answers2

0

I don't think you can use wild-char in in the effective user ID flag for pkill ... looks like only a coma separated list of UID or usrnames. You might be able to work around the issue with something like this:

pkill -9 -u $(awk -F: '/^gitlab.*/ {printf("%s,",$1)}' < /etc/passwd)
louigi600
  • 716
  • 6
  • 16
  • I see the last "," with nothing behind it makes a mess ... you'll haveto remove it else you will kill unwanted stuff pkill -9 -u $(awk -F: '/^gitlab.*/ {printf("%s,",$1)}' < /etc/passwd) |sed 's/, *$//') might do it right – louigi600 Mar 20 '17 at 11:03
0

You can use user ID to kill the process. Get the user id i.e. a unique integer number of user by running:

id <username>

And then kill all the processes by using the same command, use userid i.e. the integer number instead of username.

Hope this helps.

Gaurav Pathak
  • 1,065
  • 11
  • 28