Node.js Reference ยท process
Node.js process.title
Reference for process.title in Node.js: read or change the name shown in ps and Task Manager, platform limits, and why it helps with cluster workers.
process.title is a string that tells you the title of the running process, the name that tools such as ps, top and Task Manager display. By default it is node (or the full command line on some platforms). You can assign a new value to rename the process, which makes it easier to tell several Node.js processes apart.
The setting is limited by what the operating system allows, so assignments may be truncated.
process.title = 'my-worker'; console.log(process.title);
Try it
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.
Press Run (or Ctrl + Enter) to see the result here.
Program input ยท what you'd type while the program runs
Type the answers before you press Run, one per line. Each time the program reads a line (with node:readline or process.stdin), it gets the next line from this box.
Syntax
process.title: string
| Operation | Description |
|---|---|
process.title |
Reads the current title. |
process.title = value |
Sets the title; the value is converted to a string. |
Returns: a string. There is no error for an unsupported platform; the assignment just has limited effect.
Usage notes
- Visible to operators. Use titles like
myapp:webormyapp:worker-2sopsandpgrepshow what each process does.pkill -fandpgrep -fmatch against the command line or title. - Length limits. On Linux the title can be only as long as the original command line and environment area; on macOS and Windows the limits differ. Keep titles short.
- Windows. The title is the console window title when attached to a console, and can behave differently when no console exists.
- Not a security feature. Anyone with access to the process list can read it. Never put secrets or tokens there.
- Cluster workers are good candidates: set the title in the worker branch so you can see which PID is which.
- Changes only the process, not the file name of the script or the
argvarray.process.argvstays the same. - Reading is cheap. It is a getter backed by the OS, so repeated reads can differ if something else renames the process (rare).