1

I want to schedule a cron job in Google App Engine.

I have a url that I would like to call, this is the job.

I am not cron job knowledgeable, but the developer of the files I want to run provided the command line I am to run.

I read the Google App Engine PHP cron job documentation, and I understand the scheduling part. From the documentation's example, I would use the path "/backup." However, I don't know how would I write the file to enter the command.

This is a link to the documentation: https://developers.google.com/appengine/docs/php/config/cron

THE SCHEDULING PART (I understand this):

file cron.yaml

cron:
- description: weekly backup
  url: /backup
  schedule: every monday 05:00
  timezone: America/Los_Angeles

The cron command line (if this is what is called) is:

curl -b /tmp/cookies.txt -c /tmp/cookies.txt -L --max-redirs 1000 -v "http://somedomain.com/index.php?option=someoption&view=someview&key=somekey"

Notice I am calling a url, the url is NOT in the GAE

I am using the GAE PHP SDK

Where would I write the cron command?

What is file extension for this code?

IberoMedia
  • 2,226
  • 7
  • 36
  • 61
  • 2
    Your "developer" doesn't know what app engine is. He wants that curl command to run on some random unix server somewhere; it can't be run directly on app engine. – Wooble Feb 21 '14 at 12:28
  • So you give me a negative vote for asking? – IberoMedia Feb 21 '14 at 13:49

1 Answers1

1

Your Cron will call the backup url at every monday at 5 am

cron:
- description: weekly backup
  url: /backup
  schedule: every monday 05:00
  timezone: America/Los_Angeles

Create a php handler for that, and use the same logic the developer provided inside the backup handler.

So at 5 am the cron runs -> requests /backup -> curls the url you want or whatever

EDIT

I forgot that GAE does not support curl. Use urlfetch if possible. Also look at wrappers and this nice answer about this matter

Community
  • 1
  • 1
Jimmy Kane
  • 16,223
  • 11
  • 86
  • 117
  • Thank you Jimmy, but I think GAE does not support cURL. I got error "Fatal error: Call to undefined function curl_init() in /base/data/home/apps/my-app/1.34523456456456/somefile.php on line 15" and also I came accross fetchUrl documentation from GAE: https://developers.google.com/appengine/docs/php/urlfetch/ – IberoMedia Feb 21 '14 at 14:27
  • I placed cRUL script on the outer server, and scheduled it to be called from GAE with urlfetch, thanks – IberoMedia Feb 22 '14 at 06:54
  • @IberoMedia that will do great. As a small detail the cron from gae try to make it a secure admin login hanlder. So that people having access to /backup want call the script. – Jimmy Kane Feb 22 '14 at 14:48