0

I am having problems when running cron jobs on App Engine.

I have an App Engine Flex custom application running (using php:7.0-apache)

I also have an URL that I can call to run my job, let's say myapp.com/cacheupdate.php, when I point to that URL everything works fine, as the cache is updated correctly.

So I added a cron job:

    cron:
    - description: "Update Cache"
    url: /cacheupdate.php
    schedule: every 30 minutes

The cron job shows up in the console but always gives an error. So I added a handler for it in my app.yaml file:

    handlers:
    - url: /updatecache.php
     script: /cacheupdate.php

I have tried a few different ways to specify the source URL, but the problem persists.

I'm assuming the issue here is that I'm using a custom Docker image to build the instances, is there a better way to run cron jobs or have I missed something?

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • The cron service is just an automated `GET` request at the specified URL. If the same URL works manually the issue is elsewhere. The usual suspect is authentication: cron doesn't run with a regular user's credentials. What do you see in the app logs? – Dan Cornilescu May 11 '18 at 23:20
  • Is your handler in the default service? If not you may have to set a `target` option in your cron.yaml file: https://cloud.google.com/appengine/docs/flexible/php/scheduling-jobs-with-cron-yaml#about – LundinCast May 12 '18 at 12:13
  • when i see the failure on the cron job page i don't see anything in the log, the url works even with out me logged into the application (ive removed everything from the file apart from an echo line to test with.) I assume the cron job just uses the url of the project and then the url entry for the job? – Robert Bryden May 12 '18 at 16:35
  • @RobertBryden have you checked the [firewall settings](https://cloud.google.com/appengine/docs/flexible/python/creating-firewalls#allowing_requests_from_your_services)? You have to open both `10.0.0.1` and `0.1.0.40` so that your Flex service can receive requests from cron. – A.Queue May 28 '18 at 12:58

0 Answers0