I've just tried the following command on my Ubuntu, it doesn't show a thing:
pgrep php5
shouldn't it return the process id of php5(which the following command just does)?:
ps aux | grep php5
So, what's the difference between these two commands?
bashcommand linetext;
I've just tried the following command on my Ubuntu, it doesn't show a thing:
pgrep php5
shouldn't it return the process id of php5(which the following command just does)?:
ps aux | grep php5
So, what's the difference between these two commands?
Best Answer
ps aux
includes the full command line (path and parameters), while pgrep only looks at the first 15 characters of the executable's namesps aux
returns the full command line of each process, whilepgrep
only looks at the names of the executables.That means that grepping
ps aux
output will match anything that occurs in the path or the parameters of a process' binary: e.g. `ps aux | grep php5
will match/usr/share/php5/i-am-a-perl-script.pl
pgrep php5
won'tTake an example from my system -- only we'll use python instead of
php5
:ps aux | grep python
gives us:pgrep python
returns only11729
, which you'll see from the above list is: