扫描二维码关注官方公众号
返回列表 发布新帖

智简魔方定时任务异常怎么办?不能定时通知服务器到期信息

271 0
发表于 2024-11-3 13:05:01| 字数 5,097 | 查看全部 阅读模式 来自 浙江杭州
本帖最后由 欧云官方号 于 2024-11-3 13:10 编辑

如图,在智简魔方这套服务器对接销售的系统中,创建定时任务可以自动在服务器快到期前提醒用户及时续费。
image.webp


但是这个定时任务明明创建了,手动执行无数次,还是提示失败怎么办?
打开宝塔的计划任务,查看日志如下:

  1. PHP Fatal error:  Uncaught think\exception\ErrorException: Method ReflectionParameter::getClass() is deprecated in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php:464
  2. Stack trace:
  3. #0 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(464): think\Error::appError()
  4. #1 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(435): think\Container->bindParams()
  5. #2 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(282): think\Container->invokeClass()
  6. #3 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(132): think\Container->make()
  7. #4 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/exception/Handle.php(42): think\Container::get()
  8. #5 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Error.php(52): think\exception\Handle->report()
  9. #6 [internal function]: think\Error::appException()
  10. #7 {main}
  11.   thrown in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php on line 464

  12. Fatal error: Uncaught think\exception\ErrorException: Method ReflectionParameter::getClass() is deprecated in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php:464
  13. Stack trace:
  14. #0 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(464): think\Error::appError()
  15. #1 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(435): think\Container->bindParams()
  16. #2 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(282): think\Container->invokeClass()
  17. #3 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(132): think\Container->make()
  18. #4 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/exception/Handle.php(42): think\Container::get()
  19. #5 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Error.php(52): think\exception\Handle->report()
  20. #6 [internal function]: think\Error::appException()
  21. #7 {main}
  22.   thrown in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php on line 464
  23. PHP Fatal error:  Uncaught think\exception\ErrorException: Method ReflectionParameter::getClass() is deprecated in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php:464
  24. Stack trace:
  25. #0 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(464): think\Error::appError()
  26. #1 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(435): think\Container->bindParams()
  27. #2 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(282): think\Container->invokeClass()
  28. #3 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(132): think\Container->make()
  29. #4 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/exception/Handle.php(42): think\Container::get()
  30. #5 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Error.php(52): think\exception\Handle->report()
  31. #6 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Error.php(91): think\Error::appException()
  32. #7 [internal function]: think\Error::appShutdown()
  33. #8 {main}
  34.   thrown in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php on line 464

  35. Fatal error: Uncaught think\exception\ErrorException: Method ReflectionParameter::getClass() is deprecated in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php:464
  36. Stack trace:
  37. #0 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(464): think\Error::appError()
  38. #1 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(435): think\Container->bindParams()
  39. #2 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(282): think\Container->invokeClass()
  40. #3 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php(132): think\Container->make()
  41. #4 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/exception/Handle.php(42): think\Container::get()
  42. #5 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Error.php(52): think\exception\Handle->report()
  43. #6 /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Error.php(91): think\Error::appException()
  44. #7 [internal function]: think\Error::appShutdown()
  45. #8 {main}
  46.   thrown in /home/www/wwwroot/魔方网站目录/vendor/thinkphp/library/think/Container.php on line 464
  47. ----------------------------------------------------------------------------
  48. ★[2024-11-03 12:26:54] Successful
  49. ----------------------------------------------------------------------------
复制代码
分析日志可以发现,主要是/vendor/thinkphp/library/think/Container.php 中使用的 ReflectionParameter::getClass() 方法已被弃用(deprecated)导致的。
这个方法在 PHP 8.0 开始被弃用,意味着它在将来的 PHP 版本中可能会被移除。
原因很简单,就是你同时安装了php7.2、7.3、8.0等太多版本,主要就是最新安装的8.0导致的。
因为每次安装新版本后,系统默认的命令行会切换为最新安装的php版本,比如有时候我们先安装8.0在安装7.3就不会出现这个错误异常的。
不相信的话可以打开命令行,输入php -v就能看到当前版本号如图,我明明也安装了7.3,却只显示8.0
image.webp

这时候有两种解决方法

方法一(不推荐)
宝塔面板==》网站==》php项目==》高级设置==》php命令行版本==》设置为php73
image.webp
缺点 万一后面需要用到其他的php版本,安装后,这里就变了,忘了设置,就又开始失败而不自知了

方法二(★推荐)
直接修改定时任务命令,指定php版本
比如我的命令如下,开头只有php就是说采用的系统默认的php版本(方法一中设置的)
  1. php /home/www/wwwroot/你的网站目录名/think cron
复制代码
指定php为7.3,则修改开头的php为php73,修改后如下
  1. php73 /home/www/wwwroot/你的网站目录名/think cron
复制代码
缺点 万一后面换服务器时,你给这个程序装了比如php7.2魔方也是支持的,但是开头的php73没改成php72,那因为你没安装php73也会导致失败

这时候再到计划任务里,点击日志==》清空==》执行==》刷新,就会看到已经成功了的样子
打开魔方后台刷新,可以发现也恢复正常了

总结
一般我们使用魔方,建议都是php73,因为版本新点,支持东西更多。一般不会换别的版本,换别的你也用不了,根本打不开。所以方法二是我最推荐的。

免责声明

信息及内容: 内容仅代表用户个人观点,与本论坛无关。本论坛不保证内容的准确性、完整性或时效性,使用请自行判断和承担风险。

法律责任: 用户对其发布内容负全责,包括但不限于版权、隐私、诽谤等。因使用本论坛内容导致的任何损失,本论坛不承担责任。

版权与隐私: 请勿发布侵犯他人版权或涉及隐私的信息。发现侵权行为,请立即联系我们处理。

第三方链接及广告: 本论坛不对第三方网站或资源的内容负责。用户因访问或使用第三方内容或广告进行的交易和产生的损失,本论坛不承担责任。

用户行为: 用户需遵守论坛规则和法律法规,不得发布违法、侮辱性或不恰当内容。我们有权删除违反规则的内容并采取相应措施。

联系我们: 如有疑问或发现违规行为,请联系管理员:865817711@qq.com

回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

投诉/建议联系

865817711@qq.com

未经授权禁止转载,复制和建立镜像,
如有违反,追究法律责任
  • 关注公众号
  • 添加微信客服
Copyright © 2001-2025 第一论坛网 版权所有 All Rights Reserved. 浙ICP备2023009069号-17|浙公网安备33010602013740号
关灯 在本版发帖
扫一扫添加微信客服
QQ客服返回顶部
快速回复 返回顶部 返回列表