How to check running tasks in PHP?

In PHP, you can use the exec() function to run system commands and save the output to a variable. To view the tasks currently running, you can use the ps command.

Here is an example code:

$command = "ps aux | grep '正在运行的任务的关键词'";

$output = shell_exec($command);

echo "<pre>$output</pre>";

Replace the keywords of the running task with the keywords of the task you want to view. This command will list all running processes using the ps aux command and filter out lines containing the keywords using the grep command. Finally, execute the command using the shell_exec() function and save the output in the $output variable.

By running this code in the browser, you will see relevant information about the running tasks that match the keywords on the page.

bannerAds