node.js - How to start nodejs in background and restart all 10 minutes -
^topic
i have debian 8 now.
i have 2 node files want run 2 files
program 1 should start nodejs /home/bots/server/server.js after need timeout 10 sec. programm 2 should start after 10 secounds when program 1 started. nodejs /home/bots/f.js
thanks
i found here nothing work :/
i assume java
tag should javascript
since looks you're talking nodejs.
it's bit hard tell you're trying do, can launch new processes within nodejs using child process module either .exec()
or .spawn()
.
so, if have 1 nodejs process running already, can use settimeout()
, child process module launch process @ future scheduled time.
for example, here's example child_process doc pages wrapped inside settimeout()
:
const exec = require('child_process').exec; settimeout(function() { const child = exec('cat *.js bad_file | wc -l', (error, stdout, stderr) => { console.log(`stdout: ${stdout}`); console.log(`stderr: ${stderr}`); if (error !== null) { console.log(`exec error: ${error}`); } }); }, 10 * 1000);
Comments
Post a Comment