How to stagger cron jobs

1,160 views
Skip to first unread message

GAEfan

unread,
Nov 9, 2009, 11:18:49 PM11/9/09
to Google App Engine
Is there a way to control the exact times of execution of cron jobs,
so as to stagger them, so they don't all execute at the same time?

I see you can schedule like this:

schedule: every day 09:00

But can you also schedule the time(s) for crons that are more frequent
than daily? For example, let's say you have 5 crons that execute
every 30 minutes. Instead of having them all go off on the hour and
half hour, can you specify a start time, like:

1) every 30 minutes 0:00
2) every 30 minutes 0:05
3) every 30 minutes 0:10
4) every 30 minutes 0:15
5) every 30 minutes 0:20

-or-
1) every 1/48 day 0:00
2) every 1/48 day 0:05
3) every 1/48 day 0:10
4) every 1/48 day 0:15
5) every 1/48 day 0:20

Thank you.

Ikai L (Google)

unread,
Nov 10, 2009, 6:30:34 PM11/10/09
to google-a...@googlegroups.com
You won't be able to bulk specify a manual time, but there shouldn't be a maximum number of scheduled jobs, so you could throw together a script that generates each time individually if you need that level of granularity. Alternatively, if you are looking to operate on a subset of your data, you could maintain state in the datastore and have your handler check this per execution - I wouldn't rely on the timestamp to indicate which iteration you are in.

You may also want to look using the task queue API in conjunction with scheduled jobs: at a certain time, you push jobs into the queue, which will then take care of distributing the work out amongst your instances.
--
Ikai Lan
Developer Programs Engineer, Google App Engine

Nick Johnson (Google)

unread,
Nov 12, 2009, 6:19:03 AM11/12/09
to google-a...@googlegroups.com
Hi GAEfan,

It's not currently possible to set exact times for jobs that are more frequent than daily. The App Engine runtime will schedule them regularly, but at times it sees fit. If you need them to run at specific times you could, for example, run a daily cron job that enqueues task queue tasks to run at the desired times throughout the day.

-Nick Johnson

On Tue, Nov 10, 2009 at 4:18 AM, GAEfan <ken...@gmail.com> wrote:
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To post to this group, send email to google-a...@googlegroups.com
To unsubscribe from this group, send email to google-appengi...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---




--
Nick Johnson, Developer Programs Engineer, App Engine
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047
Reply all
Reply to author
Forward
0 new messages