Sattanathan
Sattanathan

Reputation: 463

Cron job failed in Google App Engine Flexible environment

I m migrating my PHP application from Google App engine Standard Environment to Flexible environment.

My application working fine with database and send grid. But Cron jobs are failed.

I could not find what I missed to run a Cron job in GAE Flexible environment.I gave sample application code here.

app.yaml

runtime: php
env: flex

runtime_config:
document_root: web

handlers:

- url: /crontest
script: crontest.php

- url: .*
script: index.php

#[START env]
env_variables:
MYSQL_DBNAME: CRONDB
MYSQL_USER: root
MYSQL_PASSWORD: root123
MYSQL_CONNECTION: /cloudsql/project-id:us-central1:testphp7
#[END env]

#[START cloudsql_settings]
# Use the connection name obtained when configuring your Cloud SQL instance.
beta_settings:
cloud_sql_instances: "project-id:us-central1:testphp7"
#[END cloudsql_settings]

cron.yaml

- description: cron test
url: /crontest
schedule: every day 17:00
timezone: Asia/Kolkata

web/connection.php

<?php    
    $con = new mysqli(null,$_SERVER['MYSQL_USER'],$_SERVER['MYSQL_PASSWORD'],$_SERVER['MYSQL_DBNAME'],null,$_SERVER['MYSQL_CONNECTION']);
?>

web/crontest.php

<?php

include "connection.php";

$ATERM_spcallstmt="INSERT INTO SAMPLE(TEST_NO)VALUES('9876')";
$con->query($ATERM_spcallstmt);
?>

web/index.php

<?php
echo " Test Cron in FE";
?>

Create table Query:

CREATE TABLE SAMPLE(TEST_NO VARCHAR(250));

Log from API Console

18:57:00.000172.18.0.3 - - [02/May/2017:13:27:00 +0000] "GET /crontest.php HTTP/1.1" 404 162 "-" "AppEngine-Google; (+http://code.google.com/appengine)"
{
textPayload: "172.18.0.3 - - [02/May/2017:13:27:00 +0000] "GET /crontest.php HTTP/1.1" 404 162 "-" "AppEngine-Google; (+http://code.google.com/appengine)" "
insertId: "epwcgng8mcw86z"
resource: {…}
timestamp: "2017-05-02T13:27:00Z"
labels: {…}
logName: "projects/project-id/logs/appengine.googleapis.com%2Fstdout"
}

I got HTTP 404 & Cron Failed.

Please help me to fix this.

Thanks in advance.

Upvotes: 0

Views: 592

Answers (1)

Takashi Matsuo
Takashi Matsuo

Reputation: 3436

It looks like the cron is trying to accessing /web/crontest.php which is incorrect path in your case. I suspect you still have old cron config alive?

Upvotes: 1

Related Questions