【发布时间】:2015-03-31 18:49:46
【问题描述】:
我正在开发一个命令行调度程序,因为我需要在不同时间依次运行多个命令。
public static function set ($dir, $operation, $arguments = [], $options = [], $timeToWait)
{
$argumentstring = '';
$optionstring = '';
foreach($arguments as $argument)
{
$argumentstring .= $argument.' ';
}
if ($options)
{
foreach ($options as $key => $option)
{
$optionstring .= '--' . $key . '=\"' . $option . '\" ';
}
}
$command = $operation. ' ' . $argumentstring . ' ' . $optionstring;
return $string = exec('echo php '.$dir.'/./prices '.$command.' | /usr/bin/at -M now + '.$timeToWait. ' min');
}
像这样称呼
Schedule::set(getcwd(), 'put:acknowledge', ['Customer' => database_connector::getUserId(), 'ReportId' => ReportIdDeclaration::getReportID(), [], 5);
首先,cron 运行第一个进程,然后根据 API 响应调度其他命令。我必须每两分钟运行一次这些命令,所以cron 和at 也经常被解雇。虽然我知道 cron 正在工作(并且文件中的命令在手动调用时按预期工作),但某些作业失败/未执行。
由于我没有与at 合作过这么多的工作,我怀疑at 是否像我需要的那样可靠。或者我的代码缺少我看不到的东西。
这就是我的问题的重点,at 在大量工作中是否被认为是可靠的,我是否必须控制我的源代码的错误,或者at 只是不被认为是可靠的足以在纯程序化执行的环境中工作?
【问题讨论】:
标签: php cron command-line-interface at-job