Home > Article > Backend Development > How to determine program running status in PHP
In Linux systems, when running some scripts, they often need to be placed in crontab to run regularly. After a long time, there will be a problem, that is, the repeated running of the program consumes too many resources. How to deal with it? Written two methods: The first one: Use regular matching in Linux
Call: if (ifrun('pooy',5)) { die("pooy is running"); } Note: pooy is the name of the program pooy.php! The second method: write the process into the file, then use the file function to read and match the string
Note: "www/pooy" is the string contained in the program! Now the PHP program will run much more smoothly on Linux. Editor’s summary: When debugging some simple PHP programs in a Linux system, especially PHP programs that need to be executed regularly, crontab is a good choice. It is similar to the scheduled tasks under Windows, but it is more convenient than under Win. It is recommended that you try it more. |