我正在使用命令行调度程序,因为我需要在不同时间在几分钟之后运行多个命令。
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
只是不被认为足够可靠以在纯粹的程序执行环境中工作?