假设您使用的是基于Unix的操作系统:
您可以通过exec()函数运行shell命令:
// in php file// to start the script exec("node myscript.js &", $output);$output变成输出的每一行的数组,因此您可以看到进程ID是什么。然后,您将使用该进程ID杀死脚本:
exec("kill " . $processid);
假设您使用的是基于Unix的操作系统:
您可以通过exec()函数运行shell命令:
// in php file// to start the script exec("node myscript.js &", $output);$output变成输出的每一行的数组,因此您可以看到进程ID是什么。然后,您将使用该进程ID杀死脚本:
exec("kill " . $processid);