/**
* Created by Administrator on 2018/2/25 0025.
*/
var https = require(‘http‘);
var schedule = require(‘node-schedule‘);
var rule = new schedule.RecurrenceRule();
// rule.second = [0,10,20,30,40,50];//隔十秒
// rule.hour =0;rule.minute =0;rule.second =0;//每天0点执行
rule.minute = [0,20,40];//每小时的0分钟,20分钟,40分钟执行
var j = schedule.scheduleJob(rule, function(){
httpGet();
console.log(‘现在时间:‘,new Date());
});
function httpGet() {
var uri = "http://baidu.com"
https.get(uri, function (res) {
console.log("状态码: " + res.statusCode);
})
}
原文地址:http://blog.51cto.com/itafei/2087042
时间: 2024-10-20 01:03:49