Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
[root@server1 ~]# perl file.pl & echo dog > custom-out.log & [1] 24265 [2] 24266 cat [root@server1 ~]#
我想知道我怎么能做到这一点,但同时又不让它回响
[1] 24265 [2] 24266
如您所见,我有 perl.pl 需要一点时间。我只想要回声的结果。所以我只想立即将“cat”作为输出并打破控制台,以便 php 中的 ssh2 可以读取结果。因此我需要这个的原因。
指出进程已被后台处理的消息正在由 shell 写入 stderr。如果你将它包装在一个子外壳中并丢弃它的标准错误,你可能会得到你所期望的。
( perl file.pl & echo dog > custom-log.out & ) 2>/dev/null
也就是说,您几乎肯定希望将其放入实际文件中并从您的 PHP 代码中执行,而不是依赖它正确调用 shell。