I've specified a cron job (to test in development) but it doesn't seem to be running. How does one make sure the jobs will work in production?
cron.yaml:
cron:
- description: cron test gathering
url: /test/cron
schedule: every 2 minutes from 09:00 to 23:00
app.yaml:
application: cron_test
version: 1
runtime: python
api_version: 1
handlers:
- url: /.*
script: main.py
main.py:
url_map = [ ('/test/cron', test.CronHandler),
('/error', err.Err404Handler)]
application = webapp.WSGIApplication(url_map, debug=False)
def main():
wsgiref.handlers.CGIHandler().run(application)
if __name__ == "__main__":
main()
FeedCron is defined as:
class CronHandler(webapp.RequestHandler):
def get(self):
logging.info("NOTE: CronHandler get request");
return None
I was expecting to see the line, "NOTE: CronHandler get request", in the app engine's logs. I'm using the GoogleAppEngineLauncher app (version: 1.5.3.1187) to start & stop the app.
Three years later things have improved.
First, the route to Cron Jobs is:
http://localhost:8000/cron
The development server (still) doesn't automatically run your cron jobs. However, using the link above you can do two things:
I was looking for a way to simulate cron jobs on the local dev server. As a temporary solution, I am running locally a python script which access the cron url and trigger the schedule task.
In my case the url is
http://localhost:9080/cron/jobs/
and I run it every minute. Hope it can help.D'Oh! Just saw the fine print in the SDK documentation:
Well, my UI & backend codebase were decoupled. So I whipped up some ajax code on the UI to regularly hit the backend cron endpoints. That simulated the cron jobs for me in the local dev environment.