OS

os.uptime()

Reports system uptime in seconds rather than the age of the current Node process. Do not equate this with the availability of any individual service. Tested on Node.js 22.16.0. Example output (one line per entry): ["true"].

Formal Syntax & Structure

nodejs syntaxnodejs
os.uptime()

Return Value

number

System uptime seconds.

Working Example

Example Snippetnodejs
import os from 'node:os';console.log(os.uptime() >= 0);
Node.js Reference