The php daemon is always there but still hangs from execution after running for a long time.

Code first: (No frame, all native)

`script.php`:

reqiure_once("path/to/HandleClass.php");
function run(){
    //
    if(A==B) {
        // HandleClassDB,
        new HandleClass();
    }
}

while(true){
    run();
    sleep(600);
}

`supervisor`, 

there is a problem:

  • script will appear process in about half a month, a month or so, but don"t do anything .
  • looking up the data, it is said that variables, DB and other resources may be released for a long time, but I think that after sleep , re- run () is a new execution, and there is no suspension caused by the released resources ( is the biggest confusion ).

ask for advice:

  1. what may be the reason for the suspension of the above processes has been bothering us for a long time.
  2. Please aim at this situation only. If you change the answer to crontab directly, you won"t have to pay for it: -)
Mar.17,2021

print the log, after sleep


I disagree with the idea that

resources are released for a long time . One of my projects uses pure PHP multi-process daemon processing tasks, and I have no problem running for more than a year.

I haven't seen anything wrong just from the code. Can I add more running logs to help troubleshoot the problem?


processes no longer represent anything. You can add log writing operations to both the beginning and the end of the while, and then write the log to a file, which is nothing more than a timestamp, as well as the current memory usage memory_get_usage () , as well as the length of execution, and so on. Record for a period of time, until the situation you said, take a look at the log file, make a comparison, you should be able to find clues.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b377cb-2c08f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b377cb-2c08f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?