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