[英]Catch background process error in PHP?
How can I catch a background process error in PHP? 如何在PHP中捕获后台进程错误? I am running some commands to convert a PDF but sometimes the process gets killed.
我正在运行一些命令来转换PDF,但是有时该过程会被终止。 Is there anyway to monitor if the process has been completed successful ?
无论如何,是否有必要监视该过程是否成功完成?
You can use system like flaging. 您可以使用类似标记的系统。 on start up of each background process keep a separate flag_processId = 0 for those process and on successful completion of that process update that flag to 1. and if that process getting any error in between and if it is detactable then update it to not completed flag (eg flag = 2).
在每个后台进程启动时,为这些进程保留一个单独的flag_processId = 0,并在该进程成功完成后,将该标志更新为1。如果该进程之间有任何错误,并且可确定,则将其更新为未完成标志(例如,标志= 2)。
By this you can keep track of that background process dynamically. 这样,您可以动态跟踪该后台进程。
or for detecting killing reason you can also use logging to log file. 或者,为了检测杀死原因,您也可以使用日志记录日志文件。
after each step in that process log completion of that step in log file, by this you can get where your process is getting killed. 在该过程中的每个步骤完成后,将该步骤记录到日志文件中,从而可以确定进程被杀死的位置。
Wrap the background process in a script which monitors it. 将后台进程包装在监视它的脚本中。
error_log
file in the folder where script is residing. error_log
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.