Is this on Linux?
There are actually a few subtly different versions of the command name that are used by
The two main variants are: 1) the long command name, which is what you get when you run
ps u; and 2) the short command name, which is what you get when you run
ps without any flags.
Probably the biggest difference happens if your program is a shell script or anything that requires an interpreter, e.g. Python, Java, etc.
Here's a really trivial script that demonstrates the difference. I called it
After running it, here's the two different types of
$ ps -p 5290
PID TTY ... CMD
5290 pts/6 ... mycat
$ ps u 5290
USER PID ... COMMAND
mikel 5290 ... /bin/sh /home/mikel/bin/mycat
Note how the second version starts with
Now, as far as I can tell,
killall actually reads
/proc/<pid>/stat, and grabs the second word in between the parens as the command name, so that's really what you need to be specifying when you run
killall. Logically, that should be the same as what
ps without the
u flag says, but it would be a good idea to check.
Things to check:
- what does
cat /proc/<pid>/stat say the command name is?
- what does
ps -e | grep db2 say the command name is?
ps -e | grep db2 and
ps au | grep db2 show the same command name?
If you're using other ps flags too, then you might find it simpler to use
ps -o comm to see the short name and
ps -o cmd to see the long name.
You also might find
pkill a better alternative. In particular,
pkill -f tries to match using the full command name, i.e. the command name as printed by
ps u or
ps -o cmd.