I have a script that takes 10 minutes to run:
我有一个需要10分钟才能运行的脚本:
php /path/to/script.php
If I run it as above it prints out feedback along the way like so:
如果我按上面的方式运行它会像这样打印出反馈:
> php /path/to/script.php
1 file_a.txt processed in 4.3 seconds
2 file_b.txt processed in 3.5 seconds
...
But I'd like to run several of these processes in parallel like so:
但我想像这样并行运行其中几个进程:
> php /path/to/script.php &>/dev/null &
> php /path/to/script.php &>/dev/null &
But every time I do this, I see that the previous one is stopped like this:
但每次我这样做,我都会看到前一个像这样停止:
> php /path/to/script.php &>/dev/null &
[1] 11206
> php /path/to/script.php &>/dev/null &
[1]+ Stopped php /path/to/script.php &>/dev/null
How can I run many of these scripts at once?
如何一次运行许多这些脚本?
So far I've tried:
到目前为止,我已经尝试过:
> php /path/to/script.php &
> php /path/to/script.php &/dev/null &
> nohup php /path/to/script.php &
nohup: ignoring input and appending output to `nohup.out'
I also have error_reporting(E_ALL)
set and no errors show up when running manually.
我也设置了error_reporting(E_ALL),手动运行时不会显示任何错误。
UPDATE
Thanks to generous commenters, the following works:
感谢慷慨的评论者,以下作品:
php /path/to/script.php < /dev/null &
1 个解决方案
#1
1
php /path/to/script.php < /dev/null
Or silence the script with:
或者用以下内容使脚本静音
php /path/to/script.php < /dev/null &>/dev/null &
#1
1
php /path/to/script.php < /dev/null
Or silence the script with:
或者用以下内容使脚本静音
php /path/to/script.php < /dev/null &>/dev/null &