List process by name excluding grep
You can use a trick :
ps aux | grep '[f]fmpeg'
Here []
is a format used for indicating range of characters to match using grep
, we are using [f]
to match only f
. As the [f]
is converted into f
already, the literal ps aux | grep 'ffmpeg'
won't show up in ps
output.
Also note that appearance of ps aux | grep 'ffmpeg'
on the output of ps aux | grep 'ffmpeg'
mainly depends on the time it takes for the process table to be shown.
Note that there is a program named pgrep
to search for processes, you can us that if ps aux
is not absolutely needed.
Related videos on Youtube
Maxim V. Pavlov
Updated on September 18, 2022Comments
-
Maxim V. Pavlov over 1 year
I am trying to list all the
ffmpeg
processes that are currently running on Debian machine (Ubuntu 15).I use the following command:
ps aux | grep 'ffmpeg'
If only one
ffmpeg
process is running, I still get two results. One for the actual process, and one forgrep
that is looking forffmpeg
in the process list.max 21599 13.2 3.0 503848 92288 ? Rl 01:39 1:18 ffmpeg -f video4linux2 -i /dev/video0 -f mpeg1video -b:v 800k -r 30 http://127.0.0.1:8082/oops/1024/640/ -nostdin -nostats -loglevel fatal max 23789 0.0 0.0 13688 2172 pts/3 S+ 01:49 0:00 grep --color=auto ffmpeg
How can I modify my request so that the grep result which is actually my request is omitted from the output?