cron使用说明

API:

class SaeCron extends SaeObject { public function __construct()

//添加一个cron
public function add($url, $schedule [, $timezone = 'Beijing' [, $times = PHP_INT_MAX [, $username = NULL [, $password = NULL [, $description = '']]]]])

//删除一个cron
public function delete($url)

//删除所有cron
public function delete_all()

//获取当前应用的cron列表
public function get_list()

//获取[某个]cron的上一次执行结果,指定URL时返回一维数组,不指定URL时返回二维数组
public function get_last_result([$url])

public function errno()
public function errmsg()
public function setAuth( $accesskey, $secretkey) }


示例说明:

<?php $cron = new SaeCron();

//添加定时任务
$url = 'mycron/test1.php';
$ret = $cron->add($url, '* * * * *');
var_dump($ret);

$list = $cron->get_list();
var_dump($list[$url]);

$url2 = 'index.php';
$ret = $cron->add($url2, 'every 2 mins');
var_dump($ret);

$list = $cron->get_list();
var_dump($list);
//$cron->delete_all();

Copyright © 1996-2012 SINA Corporation, All Rights Reserved