简体   繁体   中英

How to schedule cron jobs in app engine?

I want to schedule my cron jobs as like

every 5 minutes from 6 am to 1 am and every 30 minutes from 1 am to 6 am 

How to schedule this in cron.xml within <schedule tag> and how to configure the time for <timezone> India?

You can say things like

<schedule>every 5 minutes from 10:00 to 14:00</schedule>

inside the schedule tags. If you want to have "and" then I think create multiple cron entries.

https://developers.google.com/appengine/docs/java/config/cron

Likewise you can configure the timezone:

<timezone>India</timezone>

What the specific value should be you'll have to find here:

http://en.wikipedia.org/wiki/Time_in_India

http://en.wikipedia.org/wiki/List_of_zoneinfo_time_zones

The timezone should be the name of a standard zoneinfo time zone name, as detailed on that page.

For example, for multiple timed jobs, from the docs:

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
  <cron>
    <url>/recache</url>
    <description>Repopulate the cache every 2 minutes</description>
    <schedule>every 2 minutes</schedule>
  </cron>
  <cron>
    <url>/weeklyreport</url>
    <description>Mail out a weekly report</description>
    <schedule>every monday 08:30</schedule>
    <timezone>America/New_York</timezone>
  </cron>
  <cron>
    <url>/weeklyreport</url>
    <description>Mail out a weekly report</description>
    <schedule>every monday 08:30</schedule>
    <timezone>America/New_York</timezone>
    <target>version-2</target>
  </cron>
</cronentries>

For India, you need to use Asia/Kolkata timezone, and for combining both schedules you need to create 2 cron jobs.

It will be exactly like this:

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
  <cron>
    <url>/your-endpoint</url>
    <description>Your task every 5 minutes</description>
    <schedule>every 5 minutes from 06:00 to 01:00</schedule>
    <timezone>Asia/Kolkata</timezone>
  </cron>
  <cron>
    <url>/your-endpoint</url>
    <description>Your task every 30 minutes</description>
    <schedule>every 30 minutes from 01:00 to 06:00</schedule>
    <timezone>Asia/Kolkata</timezone>
  </cron>
</cronentries>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM