我有这个功能:
var getTexts = new cronJob( '*/1 * * * *', function(){
var viewConformationEmails = "select * from clients";
ibmdb.open(ibmdbconn, function(err, conn) {
if (err) return console.log(err);
conn.query(viewConformationEmails, function(err, rows) {
if (err) {
console.log(err);
} else if (!err) {
console.log("Success")
}
for (var i = 0; i < rows.length; i++) {
// arrayOfNumbers.push(rows[i].NAME)
// arrayOfNumbers.push(rows[i].PHONE_NUMBER)
// arrayOfNumbers.push(rows[i].HOUR)
// arrayOfNumbers.push(rows[i].MINUTE)
var minute = rows[i].MINUTE;
var hour = rows[i].HOUR;
console.log(rows[i])
var stringg = rows[i]["MINUTE"] + " " + rows[i]["HOUR"] + " * " + "* " + "*"
var textJob = new cronJob( stringg, function(){
client.messages.create( { to:'xxx', from:'yyy', body:'Hello! Hope you’re having a good day!' }, function( err, data ) {});
}, null, true);
}
conn.close(function() {
});
});
});
}, null, true)
什么是应该做的是运行一个定时任务的每一个1分钟,它得到的所有结果从我的 clients
表。 我再循环的各个结果,和如果是的当前时间的和它mathces的时间在数据库,然后它将发送的信息。 然而,运行的第一个定时任务在每一个分钟,然后让我们说我etxt是应该去我们在9:15,那么它不能得到有足够快,因为它仍然是要通过一定时任务itteration. 这是我的猜测,但我不是100%肯定和我无法弄清楚为什么。 有人可以帮忙吗?