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" => "1", "app_id" => "2", "url" =& gt; " Cron/back.php "," Scheduler "=>" 2/5 12-14 * * * * "," timezone "=>" gmt-8 "],...] Failed false