1
votes

I have a problem executing a cron job in node/express application using node-cron library. The application is deployed on Google Cloud App Engine.

I want to send automatic emails every day at 9 AM, but the cron only work from Monday to Friday.

Here is my code :

 cron.schedule("0 9 * * *", () => {
  sendEmails();
 },{
    scheduled: true,
    timezone: "Europe/Paris"
  });

Thanks

1

1 Answers

2
votes

App Engine standard scales down to 0 instances if there is no traffic, if it happens that at 09:00 saturday/sunday there isn't any instance your Node cron job will not be executed.


Have you checked cron.yaml. Is this the preferred method for scheduling cron jobs in App Engine. The sheduling job would be the following:

# cron.yaml
cron:
- description: "daily summary job"
  url: /tasks/sendemail
  schedule: every day 09:00

# end cron.yaml

With schedule: every day 09:00 being the specified custom interval