Bir bash komutu anlayış yardıma mı ihtiyacınız var

1 Cevap php

Aslında php ve bash bir arada bulunuyor:

exec(sprintf("%s > %s 2>&1 & echo $! >> %s", $cmd, $outputfile, $pidfile));

I 2>&1 & echo $! orada ne anlamıyorum?

1 Cevap

2>&1 redirects stderr to stdout ve $! "Expands to the process ID of the most recently executed background (asynchronous) command".

Yani, burada ne olur:

  1. Sen adında bir dosyaya stderr'yi ve $cmd stdout iki göndermek $outputfile. Bunu olmadıysa 2>&1, dosyadaki stderr çıktı okumak mümkün olmaz.
  2. & anlamına takip eden işlem runs in the background.
  3. Sonra $cmd sonuna ($! yoluyla elde edilmiştir) PID'ini ekleme $pidfile.