我正在尝试使用 xmlapi php 创建 cron 任务。我可以使用 php API 创建 cron 任务,但是当我使用“*”时它不起作用。这是我的代码
$xmlapi = new xmlapi("123.456.7.8");
$xmlapi->password_auth(user, pass);
$xmlapi->set_debug(1);
$command = "php -q /home/user/public_html/reports/set_cron.php";
$day = '0';
$hour = '*';
$minute = '*';
$month = '*';
$weekday = '*';
$set = $xmlapi->api2_query($account, "Cron", "add_line", array(
"command" => $command,
"day" => $day,
"hour" => $hour,
"minute" => $minute,
"month" => $month,
"weekday" => $weekday
));
使用它,我必须能够创建一个每小时运行一次的 cron 任务。但这给了我错误
SimpleXMLElement Object
(
[apiversion] => 2
[data] => SimpleXMLElement Object
(
[linekey] => 3502285593
[status] => 0
[statusmsg] => "-":14: bad day-of-month
errors in crontab file, can't install.
)
[error] => "-":14: bad day-of-month
errors in crontab file, can't install.
[event] => SimpleXMLElement Object
(
[result] => 1
)
[func] => add_line
[module] => Cron
)
如果我使用它,它可以工作
$day = '1';
$hour = '1';
$minute = '1';
$month = '1';
$weekday = '1';
我想将 cron 设置为每小时运行一次。我怎样才能做到这一点?