Sina App Engine (SAE) Getting Started Tutorial-Cron (timed Task) usage

Source: Internet
Author: User

Resources
    • SAE Cron Description Documentation
What can cron do?

Cron can trigger a script on a timed basis, and the maximum frequency on the SAE is one minute at a time. You can use it to complete the business logic you need, such as regular fetching of certain Web page finishes, triggering a regular script to clean up the database, and so on.

How does cron work?

A cron job can only invoke URLs where the default version of the app is applied, and its additions and deletions need to be done through code publishing. For example your default version is 1, then your cron set in version 2 of CONFIG.YAML will be invalid and will not be executed .

To do this: edit Appname/1/config.yaml (APPNAME is your app name, 1 for the version number), and enter a description of the cron job. The SAE platform currently supports the use of natural language or Unix crontab language to describe cron tasks. Examples of natural language classes:

Name:appnameversion:1accesskey:abccron:    -description:cron test          url:mycron/test.php          schedule: $ Day of October 19:00          timezone:beijing    -description:another cron test          url:mycron/another_test.php          schedule:every mins          timezone:beijing

UNIX Crontab Syntax Example:

Then upload the app code.

The above Config.yaml custom two cron jobs, respectively, test.php and another_test.php under the code directory mycron/. The school time Zone is Beijing time, and the timing is 19:00 runs each year on October 2 and runs every 10 minutes respectively.

Specific examples of use

Create a cron.php file in the Cron directory with the following file contents:

<? PHP Echo "Hello lazy!";

To set the Config.yaml, modify the following:

---name:lazydemoversion:1...cron:    -description:cron test for tech          url:cron/crom.php          schedule:every 1 mi NS          timezone:beijing

Uploading the code, we should be able to see the cron that we just set up at this time on the SAE admin panel.

Sina App Engine (SAE) Getting Started Tutorial-Cron (timed Task) usage

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.