'Trying to execute my code every 12hours on the AWS lambda server

I have to run my code every 12 hours. I wrote the following code, and I deployed it to AWS Lambda for the code to run every 12 hours. However, I see that the code does not run every 12 hours. Could you guys help me with this?

nodeCron.schedule("0 */12 * * *", async () => {
  let ids = ["5292865", "2676271", "5315840"];
  let filternames = ["Sales", "Engineering", ""];

  await initiateProcess(ids[0], filternames[0]);
  await initiateProcess(ids[1], filternames[1]);
  await initiateProcess(ids[2], filternames[2]);
});


Solution 1:[1]

AWS Lambda is an event-driven service. It runs your code in response to events. AWS Lambda functions can be configured to run up to 15 minutes per execution. They cannot run longer than that.

I would suggest you use Amazon EventBridge to trigger your Lambda function to run on a 12-hour schedule:

  1. Create a Rule with a schedule to run every 12 hours
  2. In this Rule, create a Target, which is your Lambda function.

Then, you will be able to see if it was executed properly or not, and Lambda logs will be available in CloudWatch Logs.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 jarmod