Viewing foreground process using ps
You might be confused because ps
by default shows you the processes which are on the same terminal where ps
is invoked, e.g. processes started from the same terminal window.
Try ps -u $LOGNAME
or if you know the terminal names ps -t $THETTYNAME1,$THETTYNAME2
. (The terminal names normally look like "ttyN" or "pts/N").
Related videos on Youtube
Jeff Schaller
Unix Systems administrator http://www.catb.org/esr/faqs/smart-questions.html http://unix.stackexchange.com/help/how-to-ask http://sscce.org/ http://stackoverflow.com/help/mcve
Updated on September 17, 2022Comments
-
Jeff Schaller over 1 year
I can see the background process using ps. But Is there a way to view the foreground process? For example,
$nohup process1 &
then
ps -ef | grep "process1"
would display the process "process1" in execution. But the above command wouldn't show a foreground process executed like,
$process2
-
Admin over 13 years
ps -ef
shows all foreground processes for me. Which OS are you running on? -
Admin about 13 yearsAre you sure process2 is still running when you typing 'ps'? Maybe it's already done.
-
Admin about 11 yearsBy the time you get the prompt back, the foreground process is done.
-
Admin over 2 yearsI feel this question is misleading; see the answer below for an explanation.
-
-
bahamat over 13 years
ps - ef
shows all processes, not just ones on "this" terminal. -
Seamus over 2 yearsThis answer is incorrect - or perhaps 'insufficiently qualified'. On my macOS (which uses a
ps
with a BSD heritage), issuing theps
command with no options lists processes on all 6 terminals (ttysxxx).man ps
yields:The ps utility displays a header line, followed by lines containing information about all of your processes that have controlling terminals.