Aliyun Cron Service Description

Source: Internet
Author: User
Tags execution php code php script split aliyun

function Introduction

Cron is a timed distributed timed task service that ACE provides to developers, and can perform related tasks on a regular basis as required. For example, back.php periodically queries the database for specific messages to be aggregated to the developer. Cron's grammar rules are consistent with the syntax rules of the crontab under Linxu, but the difference with Crontab's configuration file defines cron, and Ace uses the PHP API to manage cron. Crontab is executed as HTTP, and the final access is PHP code, which automatically deletes the scheduled task if it is found to fail 5 consecutive times during execution.

Instructions for use

Follow the same syntax rules as Linux under Crontab to set cron execution time and invoke cron-related interfaces to add, delete, and view crontab. If you are unfamiliar with the setup syntax for crontab under Linux, please refer to:

Http://study.chyangwa.com/IT/AIX/aixcmds1/crontab.htm

Http://www.pantz.org/software/cron/croninfo.html

Attention:

1, Crontab is executed in HTTP, the maximum execution time of the script is 30 seconds, if the scheduled task execution time more than 30 seconds, please split the implementation;
2, Crontab is executed in HTTP, the maximum execution time of the script is 30 seconds, if the scheduled task execution time more than 30 seconds, please split the implementation;
3, crontab only to the default version of the entry into force;
4, currently support two ways, one is the way to do one time, such as: 5 o'clock every day to execute a script; one is to offset the execution of PHP, for example, every hour to execute a PHP script.

Reference sample

< PHP

Add crontab

$cron _id = Cron_add ("2/5 12-14 * * * *", "cron/backup.php");

Delete Crontab

$ret = Cron_delete ($cron _id);

Query crontab

$array = Cron_list ();

?>

API documentation

String Cron_add (String $scheduler, String $url, [string $timezone])

Add timed Task

Parameters:

Scheduler

timing rules, same as the Linux cron rules.                    The integer value range and meaning of the first to fifth field is: 0~59 represents the 1~23 of the hour 1~31 represents the day 1~12 represents the month 0~6 the week (0 for Sunday) For example 2/5 12-14 * * * * means 12 14 dots per day, every 2 minutes to start the

Url

The name of the script executed, for example: cron/backup.php

TimeZone

time zone, default is: GMT-8

return value:

successfully returns CRON_ID, that is, the timed task number; failure returns false

BOOL Cron_delete (string $cron _id)

Delete timed Tasks

Parameters:

cron_id

timed Task number

return value:

success true; failed false

Array cron_list ()

Query timed Tasks

Parameters

No

return value

Success (arrary) [["Cronid" =&gt; "1", "app_id" =&gt; "2", "url" =&amp; gt; "              Cron/back.php "," Scheduler "=&gt;" 2/5 12-14 * * * * "," timezone "=&gt;" gmt-8 "],...] Failed false

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.