我的 cronJobs 不工作。它应该每天早上向所有客户发送一封电子邮件。为什么?

问题描述 投票:0回答:0

我不得不更换 AWS 服务器。现在,新服务器不再每天早上向客户发送电子邮件(它在旧服务器上工作)。我已经看过所有代码,但没有发现任何需要更改的地方。

我已经重新启动了新服务器并通过了命令“npm run cronJobs”,但仍然无法正常工作。 任何人都知道当我们更改服务器时需要在 cronJobs 中做什么?

这是 cron 的代码:

cron.schedule("*/3 * * * *", async () => {
    console.log("PENDING ACTIVITIES");
    console.log(
      "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
    );
    console.log("running a task every 3 minutes");
    console.log(
      "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *"
    );

    // const urlBase = 'http://localhost:3000';
    const urlBase = "http://TEColab.tecomat.com.br";

    await axios.post(
      `${urlBase}/api/user/task-send-pending-activities-mail`,
      {},
      { timeout: 180000 }
    );
  });

当我重新启动服务器时,我必须传递这个命令:

git pull
npm run build
forever stop 0
forever stop 0
npm run stayAlive
npm run cronJobs

这是 cronJobs 脚本:

"cronJobs": "cross-env forever start server/cron-jobs.js"
javascript email cron npm-scripts
© www.soinside.com 2019 - 2024. All rights reserved.