gistlib
To get the system uptime in Node.js, you can use the built-in os module. Here's how:
os
const os = require('os'); const uptime = os.uptime(); // uptime in seconds console.log(`System uptime is ${uptime} seconds`); 128 chars6 lines
const os = require('os'); const uptime = os.uptime(); // uptime in seconds console.log(`System uptime is ${uptime} seconds`);
This will log the system uptime in seconds. You can convert it to minutes or hours, as needed.
gistlibby LogSnag