As mentioned in a comment, use
pm2 describe
That will produce copious output similar to the following:
┌───────────────────┬─────────────────────────────────────────────────────────────────────────────────────┐
│ status │ online │
│ name │ random │
│ namespace │ default │
│ version │ 1.0.0 │
│ restarts │ 0 │
│ uptime │ 107m │
│ script path │ /home/pi/checkout/random-monitor.ts │
│ script args │ N/A │
│ error log path │ /home/pi/.pm2/logs/random-error.log │
│ out log path │ /home/pi/.pm2/logs/random-out.log │
│ pid path │ /home/pi/.pm2/pids/random-1.pid │
│ interpreter │ /home/pi/.nvm/versions/node/v12.19.0/lib/node_modules/pm2/node_modules/.bin/ts-node │
│ interpreter args │ N/A │
│ script id │ 1 │
│ exec cwd │ /home/pi/checkout │
│ exec mode │ fork_mode │
│ node.js version │ 12.19.0 │
│ node env │ N/A │
│ watch & reload │ ✘ │
│ unstable restarts │ 0 │
│ created at │ 2020-11-18T00:17:04.623Z │
└───────────────────┴─────────────────────────────────────────────────────────────────────────────────────┘
The interpreter
, interpreter args
, script path
and script args
should give you what you are after. See also this answer to a similar question.
Note: For the sake of completeness, the actual command requires a name or argument for which process you'd like information about. In the case above the full command is pm2 describe random
where random
above is the name of the process as you can tell from the output. You may run pm2 status
to get a list of processes along with their id and name.
Note: I left the command above listed as just pm2 describe
without the argument to avoid potentially confusing error messages for cut and paste users. I think the error message pm2 describe
produces indicating a missing required argument is far less confusing than one stating that "random" is not found or even worse if I listed the argument as name|id
which would cause the output to be piped to the program id
that may or may not exist depending on the platform on which you are running.
pm2 describe
: https://mcmap.net/q/535018/-how-to-view-pm2-command-line-arguments-passed-to-node-js-at-startup – Removable