views:

432

answers:

3

I need to run a task every hour on the hour (00:00, 01:00, 02:00, ..., 23:00) every day of the week, but can't seem to find an example in App Engine's docs of how to do this.

There is an example of running at ask every hour, but this doesn't fit because the "start" of that hour depends on when you deploy the application. That is, if I deploy at 4:37 PM, the cron scripts will get executed at 5:37, 6:37, ... instead of 5:00, 6:00, ...

So far the only way that looks like it would work is to have 24 different cron entries, one for the specific hour of each day set to run each day at that specific time.

Does anyone know of anything that would let me use a schedule like "every hour at :00" or even "every day 00:00, 01:00, ... 23:00"?

A: 

Looking over the docs, I agree that your 24 cron entry idea is the only documented way that would work. Not ideal, but should work.

goger
A: 

The docs say you can have 20 cron entries, so you can't have one for every hour of the day.

You could run your task every minute and check if it is the first minute of the hour - exit otherwise.

gnibbler
+4  A: 

Unfortunately, the cron syntax doesn't let you specify the time for intervals less than a day. What you can do, however, is use the Task Queue for this. Either:

  1. Have a single task queue entry that, when it runs, enqueues a new task with the 'countdown' set to the number of seconds until the next time you want to run.
  2. Have a daily cron job that enqueues 24 hourly taskqueue entries at each of the times you want it to run.
Nick Johnson
In case anyone is curious, this method of running one task at 00:01 every day which schedules tasks to run throughout the day (using the `eta` parameter) works really well.
jgeewax