admin管理员组文章数量:1417096
I am Using Nodejs, and want trigger one function on 5:30 AM, 11:30 PM daily.
How should i follow that approach.
I also want to add more time apart from above like 9:45 PM, 5:30 PM
I have check tried but not getting any luck.
var j = schedule.scheduleJob('* * * 23 07 00', function () {
console.log('The answer to life, the universe, and everything!');
});
j.schedule()
Thanks.
I am Using Nodejs, and want trigger one function on 5:30 AM, 11:30 PM daily.
How should i follow that approach.
I also want to add more time apart from above like 9:45 PM, 5:30 PM
I have check https://www.npmjs./package/node-schedule tried but not getting any luck.
var j = schedule.scheduleJob('* * * 23 07 00', function () {
console.log('The answer to life, the universe, and everything!');
});
j.schedule()
Thanks.
Share Improve this question edited Apr 22, 2019 at 17:39 Nikhil Savaliya asked Apr 22, 2019 at 17:35 Nikhil SavaliyaNikhil Savaliya 2,1664 gold badges26 silver badges45 bronze badges 5- 1 I doubt it's a matter of luck, give a minimal reproducible example. – jonrsharpe Commented Apr 22, 2019 at 17:37
- 1 tried but not getting any luck.....that modules has 164,708 weekly downloads. It has nothing to do with luck, you're just doing something wrong. If you want an actual answer you're gonna have to be more specific – Isaac Vidrine Commented Apr 22, 2019 at 17:39
- 1 Hello Nikhil, I've voted to close your question as too broad. Please ask a more specific question, ideally including some of your code. See How to Ask – Patrick Hund Commented Apr 22, 2019 at 17:39
- 1 Great! Now whats the problem?Saying Not having any luck tells us nothing. – Isaac Vidrine Commented Apr 22, 2019 at 17:41
-
not sure how to trigger functions based on above time like
* * * 23 07 00
is 11:07 PM IST, but console didint apeard that time – Nikhil Savaliya Commented Apr 22, 2019 at 17:42
1 Answer
Reset to default 5You have specified a wrong schedule pattern.
More readable way is using objects like this:
const j = schedule.scheduleJob({hour: 5, minute: 30}, () => {
console.log('Job runs every day at 5:30AM');
});
And in case you need multiple Jobs running at different time of the day - create a few jobs with different time pattern and use the same function in each.
本文标签: javascripttrigger function on specific time daily nodejsStack Overflow
版权声明:本文标题:javascript - trigger function on specific time daily nodejs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745253813a2649980.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论