1

I'm working with Ubuntu 16 through SSH, and facing an issue with it. I want to kill the process but can't find a way because it keeps changing the PID every time.

I'm using this command to check the process is running or not, here 'geth' is my process name

ps ax | grep geth 

It showing me result as follows,

enter image description here

When I try kill the process with process name, it shows that

killall geth

geth: no process found

Div
  • 117

2 Answers2

1

As already answered, you are looking at your own grep processes. Thats why there's a new PID for each process. If you want to exclude these lines containing grep, you can execute ps ax | grep [g]eth.

BulletBob
  • 1,830
1

In Ubuntu, grep is an alias of grep --color=auto. You can confirm it by running type grep. When you run grep something, you're actually running grep --color=auto something.

Now when grep or any other command is ran, a process is created. As a result, even if some process doesn't even exist in the memory it'll produce an output which is obviously the grep process. For example, I have no application/program registered as foo. But even if I run ps aux | grep foo, I'll get:

kulfy    13544  0.0  0.0  21532  1076 pts/0    S+   23:59   0:00 grep --color=auto foo

This process will automatically die once grep has processed all the output piped from ps aux.

You can use pgrep instead. It will show process id(s) of the running processes with the name passed as an argument. It doesn't need to be piped.


Further Reading:

Kulfy
  • 18,154