Google app engine 设置Cron Jobs GAE设置定时任务(Java版)

Categories: Development Notes; Tagged with: ; @ April 20th, 2011 21:24

GAE的 Cron Job是通过配置文件实现的 – “Cron jobs are defined in cron.yaml (Python) or cron.xml (Java)”

Java版的cron.xml配置文件位于WEB-INFO目录下(位置同web.xml), 典型的一个:

<?xml version=”1.0″ encoding=”UTF-8″?>
<cronentries>
  <cron>
    <url>/GetIPLocation</url>
    <description>get the ip location by api every 2 minutes</description>
    <schedule>every 2 minutes</schedule>
  </cron>
</cronentries>

该任务每两分钟执行一次, GepIPLocation是一个Servlet.

时间格式举例:

every 12 hours
every 5 minutes from 10:00 to 14:00
2nd,third mon,wed,thu of march 17:00
every monday 09:00
1st monday of sep,oct,nov 17:00
every day 00:00

API地址: http://code.google.com/appengine/docs/java/config/cron.html (可能需要翻墙)



// Proudly powered by Apache, PHP, MySQL, WordPress, Bootstrap, etc,.