0

I was wondering if you can perform an automatic restart of a server made with node. My idea was to run a .bat file via node that rebooted the server. It's possible to do it?

2 Answers2

2

You can use exec as follows

const { exec } = require('child_process');
exec('shutdown -s -t 0') ; // change command according to your system 

check this question for more details on exec

Execute a command line binary with Node.js

Rami ZK
  • 510
  • 3
  • 13
1

Generally its possible to reboot a server with batch by calling shutdown.exe

You can execute any file with nodejs. NodeJS documentation is here.

Sebastian Waldbauer
  • 674
  • 1
  • 10
  • 17