长时间运行的PHP脚本无法获取数据

时间:2021-01-09 21:38:12

I am using a php script for polling new articles for a post. I use CURL for fetching the new data. When I run the script(main.php as ./main.php) in apache server, Its fetching the data at that time.

我正在使用PHP脚本为帖子投票新文章。我使用CURL来获取新数据。当我在apache服务器中运行脚本(main.php为./main.php)时,它在那时获取数据。

If I check the database after one day, its not updated. When I check the script, Its still running. Suggest me the good way to run the PHP 24*7 time

如果我在一天后检查数据库,它没有更新。当我检查脚本时,它仍在运行。建议我运行PHP 24 * 7时间的好方法

1 个解决方案

#1


-2  

Suggestions:

建议:

  • Make a service / daemon out of it.
  • 从中提出服务/守护进程。
  • Insert logging into your code to trace what is happening (log4php comes to mind). This allows you to monitor (tail -f) what is happening in real time.
  • 在您的代码中插入日志以跟踪发生的事情(想到log4php)。这使您可以实时监控(尾部-f)发生的情况。
  • Use restartd to restart when php crashes on an error
  • 当php崩溃时,使用restartd重启

#1


-2  

Suggestions:

建议:

  • Make a service / daemon out of it.
  • 从中提出服务/守护进程。
  • Insert logging into your code to trace what is happening (log4php comes to mind). This allows you to monitor (tail -f) what is happening in real time.
  • 在您的代码中插入日志以跟踪发生的事情(想到log4php)。这使您可以实时监控(尾部-f)发生的情况。
  • Use restartd to restart when php crashes on an error
  • 当php崩溃时,使用restartd重启