在 PHP 中,
I need to execute background tasks. So I have three choices to run script from
following commands:
1)exec
2)shell_exec
3)passthru
I randomly decided to use exec command in PHP.
Because All of these have similar characteristics.
现在我想知道有没有disadvantage of exec() command可以在后台运行的?其实我不太了解这个命令。
它是否与主线程分开线程?如果yes then,有没有办法清理或挂起这个后台线程?或者it simply forget it after firing the command?
我问这个是因为在我的代码中需要run this script very fast one after one within moments. 那么它会创建任何服务器负载吗?
编辑: 我正在使用这样的 exec 命令:
exec("/usr/bin/php /path/to/Notification.php >> /path/to/log_file.log 2>&1 &");
请指导我。任何帮助将不胜感激。