ps command: how show the complete command with options, pipes and redirection? (or all together)

About the ps command, consider if for simplicity:

  • in tty3 is executed the yes command
  • in tty4 is executed the yes > /dev/null command

through ps I need to show in the report the complete command with options, pipes and redirection, in this case redirection, was tried ps aux and ps -ef and does not appear as expected, for both cases always appear yes – I need see yes and yes > /dev/null

    yes > /dev/null

so currently the > /dev/null part is not included. How accomplish this goal?

About a command with pipe it would be mvn clean ... | tee ... and about option(s) the command would be tar -xzf /path/to/filename.tar.gz

    mvn clean ... | tee ...
    tar -xzf  /path/to/filename.tar.gz

or all together: options, pipes and redirection

Asked By: Manuel Jordan


You can’t. At least, not without deconstructing output from ps, lsof, and a little bit of guesswork.

You can use ps -ef or maybe ps -wwef to get the command with its options, but redirections and pipes are not part of a command and so will not be shown

Answered By: roaima
Categories: Answers Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.