How to find the exact process using ps aux command?

Hello Everyone,

Please help me on this,

Requirement here is to check whether the process is running using the process id.

For the below scenario, I m trying to grep 1750 process id to check if this is active or not using the below command.

$ ps aux | grep -v grep | grep 1750
cafesys  1750  0.0  0.0 109540  1880 pts/8    S+   Dec22   0:00 -ksh
rpcuser  31750  0.0  0.0  23352   720 ?        Ss   Oct17   0:00 rpc.statd
root     17504  1.9  0.0 180580 13748 ?        S<l  Nov01 1594:15 /opt/perf/bin/perfd

$

I want only the process running withe user "cafesys" to show up on my output.
others needs to be ignored. Please help me with the command on unix

If you read the manual page for ps you should see the various flags, e.g. -u for user.

I would suggest something like this:-

ps -fu cafesys

if you need to get a specific process name, you might be better with pgrep if you have it or perhaps a trick using metacharacters like this:

ps -fu cafesys | egrep ks[h]

The search string ks[h] is the literal characters ks followed by any character within the square brackets. That means that your own grep process will not be selected.

Do either of these help?

Robin

Does this fly?

ps -ef |grep $1 | grep -v grep

If you want to hard code a specific process, substitute it for "$1".

egrep ks[h] lets the shell try to substitute it by matching files.
Say you are in the /bin directory, then the shell will find ksh and substitute egrep ksh , and the egrep might find itself in the process table.
Correct is

ps -fu cafesys | grep -w "ks[h]"

--
Some OS have pgrep that gives the pid only

pgrep -xu cafesys "\-?ksh"