我有一个每分钟运行命令的cronjob。该命令执行" swiftmailer:spool:send"命令:
$this->getContainer()->get('project')->runCommand('swiftmailer:spool:send');
这是runCommand
方法:
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArrayInput;
...
function runCommand($command, array $options = array())
{
$kernel = $this->container->get('kernel');
$app = new Application($kernel);
$app->setAutoExit(false);
$app->setCatchExceptions(false);
$input = array(
'command' => $command,
'--env' => $kernel->getEnvironment(),
'--quiet' => null);
$appInput = new ArrayInput(array_merge($input, $options));
$statusCode = $app->run($appInput);
if ($statusCode) throw new \Exception("$command exited with an error $statusCode");
}
这工作了很长时间,但突然间,电子邮件每小时发送一次。甚至,如果我手动运行命令,那么它不是crontab作业问题。唯一的方法是手动运行命令:
php app/console swiftmailer:spool:send --env=prod
这是发送电子邮件的唯一方式。
如果我运行:ls -la app/cache/prod/swiftmailer/spool
,我可以看到那里的电子邮件,直到发送电子邮件。当我手动运行命令时,我没有收到任何错误,但电子邮件仍然存在但未发送。
知道这里会发生什么事吗?