dongwuqi4243 2016-08-26 20:41
浏览 127
已采纳

(CentOS 6)通过crontab运行Artisan命令会导致Reflection异常

When I run command php artisan schedule:run, it runs fine. However, when I put the command into the scheduler as follows:

* * * * * php /PATH/TO/PROJECT/artisan schedule:run >> /PATH/TO/PROJECT/storage/logs/scheduler.log 2>&1

I get the following error every time it runs.

PHP Fatal error:  Uncaught ReflectionException: Class log does not exist ...

This question shows that it's because of an error that happens early in the bootstrap process and tries to log an error before the logger is registered.

I can't seem to figure out where to start debugging since this is the only call stack I get:

PHP Fatal error:  Uncaught ReflectionException: Class log does not exist in /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php:734
Stack trace:
#0 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(734): ReflectionClass->__construct('log')
#1 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(629): Illuminate\Container\Container->build('log', Array)
#2 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(697): Illuminate\Container\Container->make('log', Array)
#3 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(849): Illuminate\Foundation\Application->make('log')
#4 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(804): Illuminate\Container\Container->resolveClass(Object(ReflectionParameter))
#5 /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php(773): Illuminate\Container\Container in /PATH/TO/PROJECT/vendor/laravel/framework/src/Illuminate/Container/Container.php on line 734

I suspect it may have something to do with permissions, however the crontab is tied to the same user who runs it manually. What is causing the original error?

  • 写回答

1条回答 默认 最新

  • duanmu1736 2016-09-08 17:46
    关注

    I've found what was causing my error in particular (it may/may not vary for others). After debugging through many source files I've found the source of the issue was that the PDO extension wasn't being loaded. I don't know why this was the case only when running as a cron-job.

    As a note: it seems that other having the same issue often have it during the configuration phase so it might be a good idea to start debugging from there if you are getting the same exception.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!