Ayman Hussein
Ayman Hussein

Reputation: 3857

cron job in google app engine did not execute php script

I have this cron.yaml file

cron:
- description: every 2 mins
  url: /api/get_source_news.php
  schedule: every 2 minutes synchronized

I put it root in app.yaml level and everything is ok as you see in log

A 11:40:00.844 2015-01-29  200     737 B   102ms /api/get_source_news.php
  0.1.0.1 - - [29/Jan/2015:01:40:00 -0800] "GET /api/get_source_news.php HTTP/1.1" 200 737 - "AppEngine-Google; (+http://code.google.com/appengine)" "cosmic-descent-775.appspot.com" ms=102 cpu_ms=70 cpm_usd=0.000082 queue_name=__cron task_name=827fc890ec19365c3ba048d35277cf46 instance=00c61b117cc3e93627a3967269e339a46d20b2dc app_engine_release=1.9.17 trace_id=0792af8b291db432a2071ac60f8ed6fd

A 11:42:00.986 2015-01-29  200     737 B    80ms /api/get_source_news.php
A 11:44:01.247 2015-01-29  200     737 B   213ms /api/get_source_news.php
A 11:46:00.419 2015-01-29  200     737 B    71ms /api/get_source_news.php
  0.1.0.1 - - [29/Jan/2015:01:46:00 -0800] "GET /api/get_source_news.php HTTP/1.1" 200 737 - "AppEngine-Google; (+http://code.google.com/appengine)" "cosmic-descent-775.appspot.com" ms=71 cpu_ms=47 cpm_usd=0.000082 queue_name=__cron task_name=827fc890ec19365c3ba048d35277cf46 instance=00c61b117cc3e93627a3967269e339a46d20b2dc app_engine_release=1.9.17 trace_id=d53952790dff0b4214a6f88c69611739

the cron call the script every 2 mins but issue is the php script did not execute and no rows effected nothing happend.

but when call url in browser the script is executed and it is ok.

what is the issue, is it a permission issue? or somthing.

Upvotes: 0

Views: 976

Answers (1)

Layo
Layo

Reputation: 687

On the url section of the cron.yaml: you should put the URL of the handler that has been assigned to your get_source_news.php script. You put the name of the script's instead. I suggest you to take a look at the documentation (https://cloud.google.com/appengine/docs/php/config/cron).

Let's suppose your app.yaml is as follow:

application: myapp
version: 1
runtime: php
api_version: 1

handlers:  
# Serve php scripts.
- url: /api/get_source_news
  script: get_source_news.php

Then, your cron.yaml should look like:

cron:
- description: every 2 mins
  url: /api/get_source_news
  schedule: every 2 minutes synchronized

Upvotes: 1

Related Questions