Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cron jobs not running (in dev)

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.

like image 445
Dan Holman Avatar asked Aug 30 '11 20:08

Dan Holman


2 Answers

D'Oh! Just saw the fine print in the SDK documentation:

When using the Python SDK, the dev_appserver has an admin interface that allows you to view cron jobs at /_ah/admin/cron.

The development server doesn't automatically run your cron jobs. You can use your local desktop's cron or scheduled tasks interface to trigger the URLs of your jobs with curl or a similar tool.

like image 143
Dan Holman Avatar answered Oct 03 '22 01:10

Dan Holman


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:

  1. Click the "Run now" button, which actually triggers the URL (hurray!)
  2. See the schedule, which should assure you of when the jobs would be run in production
like image 25
oferei Avatar answered Oct 03 '22 02:10

oferei