2

I am using google app engine and have 2 applications that use cron jobs to schedule events. I am able to deploy both applications by using gcloud app deploy app.yaml cron.yaml. Even though both apps are deployed and working, only one of the cron jobs actually runs. This is what the files look like.

First cron.yaml

cron:
- description: "GET first group"
  url: /
  schedule: every 5 minutes
  target: pubsubone

Second cron.yaml

cron:
- description: "GET second group"
  url: /
  schedule: every 5 minutes
  target: pubsubtwo

These files are in different folders and associated with different applications.

Nicky Feller
  • 3,539
  • 9
  • 37
  • 54
  • Possible duplicate of [Cron per Service/Module (AppEngine)](https://stackoverflow.com/questions/41744890/cron-per-service-module-appengine) – Dan Cornilescu Mar 26 '18 at 13:46
  • Note that you don't have 2 different applications, but 2 different services/modules inside the same GAE application (project) and that the cron config is an app-level config shared by all services in the app. – Dan Cornilescu Mar 26 '18 at 13:49

2 Answers2

3

When you deploy the second service with a new cron.yaml file, the first cron job gets overwritten since only one cron.yaml is expected for deployments. To deploy both cron jobs contemporarily join them in a single file, as shown in the example here and then deploy the resulting cron.yaml file as shown here. The cron.yaml should look like this:

cron: 
- description: "GET first group" 
url: / 
schedule: every 5 minutes 
target: pubsubone 
- description: "GET second group" 
url: / 
schedule: every 5 minutes 
target: pubsubtwo 

And the command line to deploy it is this one:

$ gcloud app deploy cron.yaml
Rubén C.
  • 1,098
  • 6
  • 16
1

There are several reasons this can be failing for you, and sorting out which will be easier if you use something other than / as the url. /cron, perhaps. That'll make it a lot easier to determine, when looking at the logs, that the url is being called as intended.

Next, there the target. If there aren't versions of your app active that have the specified value as their version (or service, though I don't have experience with that), AFAIK, the request generated by cron will get dropped on the floor.

Dave W. Smith
  • 24,318
  • 4
  • 40
  • 46