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
  • 4
    Those aren't geth processes. Instead they are grep processes which on-completion automatically dies. Instead of using ps ax | grep process_name use pgrep process_name – Kulfy Apr 02 '20 at 06:39
  • Alright, so there isn't any process of geth running on the machine. – Div Apr 02 '20 at 06:42
  • Instead they are grep processes which on-completion automatically dies How can I quit those from on-completion? P.S. I'm new to Ubuntu – Div Apr 02 '20 at 06:47
  • There is no process called geth running on your machine. What you see is the process of you looking for such a process. Try replacing geth by randomstring00300s0. – Jos Apr 02 '20 at 10:58
  • 1
    @Div I have converted my comment into an answer. – Kulfy Apr 02 '20 at 18:37
  • Thanks! @Jos I understood now – Div Apr 03 '20 at 04:42

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,780
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
  • 17,696