且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

具有cron和PHP脚本的电报机器人

更新时间:2023-11-19 12:13:22

提示:我将其添加为答案,因为我的声誉(截至目前)低于50。

到目前为止,我需要更多信息才能提供支持。这里可能存在多个潜在问题。让我们看看我们能否一起走下去。

As of now I would need more information in order to support. There might be multiple potential issues here. Let's see if we can go down the road together.

1。在执行cron期间使错误可见

在这种情况下,您可以检查cron内部的日志。我建议通过this将任何输出记录到文件中到您的cron > /var/log/my-cron.log 2>& 1

In this case you could check your logs inside your cron. I would suggest to log any output into a file by the this to your cron >> /var/log/my-cron.log 2>&1.

* * * * * /usr/bin/php /opt/bitnami/apache2/htdocs/bot.php >> /opt/bitnami/apache2/htdocs/testCron.log 2>&1

从这里开始可以检查是否有执行错误,权限错误或配置错误。

From here on we can check if there is any execution errors, permission errors or some misconfiguration.

2。检查您的错误日志配置

可能未显示您的错误。这是一些配置的一个很好的起点

It might be that your errors are not displayed. Here is a good starting point for some configuration

// tells your script to report any error
error_reporting(E_ALL); 

// tells your script to enable error logging and the location where it should log to
ini_set('log_errors', '1'); // tells your script to enable logging
ini_set('error_log', '/dev/stderr'); 

让我们看看这是否足以产生一个初步的想法或我们是否需要挖掘更深层次。

Let's see if this is enough to get an initial idea or if we need to dig deeper.