You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
shell.series(commandList , function(err,res){
// console.log('executed many commands in a row');
console.log('done')
});
});
which need to run on every 1 min but the scripts inside the cron may take more than 1 min.
I need to skip the cron for the moment when the scripts are still running .
Can anyone help me on it.
Calling cron from app.js as below code
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
var port = 3000;
require('./cronController').job.start();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.listen(port , ()=>{
let dateTime = new Date();
let message = 'Server is running on Port :- ' + port + ' started at :- ' + dateTime;
console.log(message);
});
The text was updated successfully, but these errors were encountered:
const{ spawn }=require('child_process');constgrep=spawn('grep',['ssh']);grep.on('close',(code,signal)=>{console.log(`child process terminated due to receipt of signal ${signal}`);});// Send SIGHUP to process
2- wraping your child process as js (promise)
as I see your commandList are all js script, why dont u execute them by JS function ?
I have written a cron job as given below
var cron = require('node-cron');
var taskMap = {};
let job = cron.schedule('*/1 * * * * ', ()=>{
var shell = require('./utils/child_helper');
var commandList = [
"node *****",
"node *****",
"node ******"
]
shell.series(commandList , function(err,res){
// console.log('executed many commands in a row');
console.log('done')
});
});
which need to run on every 1 min but the scripts inside the cron may take more than 1 min.
I need to skip the cron for the moment when the scripts are still running .
Can anyone help me on it.
Calling cron from app.js as below code
const express = require('express');
const app = express();
const bodyParser = require('body-parser');
var port = 3000;
require('./cronController').job.start();
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.listen(port , ()=>{
let dateTime = new Date();
let message = 'Server is running on Port :- ' + port + ' started at :- ' + dateTime;
console.log(message);
});
The text was updated successfully, but these errors were encountered: