Skip to content
Tutorials Center
My learning

Topics

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.

NODE
process.title = 'my-worker';
console.log(process.title);

Try it

Node.js Reading and changing the title

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.

Node.js Naming processes by role

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

NODE
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:web or myapp:worker-2 so ps and pgrep show what each process does. pkill -f and pgrep -f match 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 argv array. process.argv stays 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).