如何使用 PM2 制作任务作业? [英] How to make a task job with PM2?
本文介绍了如何使用 PM2 制作任务作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想做一个可重复的工作,每 15 分钟发送一次邮件,从数据库表中获取数据.在 node js 中,我可以创建作业,但通过 PM2,我不知道将代码放在哪里以及它是如何工作的.
I want to make a repeatable job to send mail every 15 minutes taking data from a database table. In node js I can create the job but through PM2 I don't understand where to place the code and how it works.
推荐答案
感谢您的回答;我是这样做的,只需设置电子邮件
thank you for your answer; i do it in this way and just set the email
1.
npm install node-crontab
var crontab = require('node-crontab');
var jobId = crontab.scheduleJob("*/15 * * * *", function(){
//This will call this function every 15 minutes
console.log("It's been 15 minutes!");
});
这篇关于如何使用 PM2 制作任务作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文