get system uptime in javascript

To get the system uptime in Node.js, you can use the built-in os module. Here's how:

const os = require('os');

const uptime = os.uptime(); // uptime in seconds

console.log(`System uptime is ${uptime} seconds`);
128 chars
6 lines

This will log the system uptime in seconds. You can convert it to minutes or hours, as needed.

related categories

gistlibby LogSnag