从PHP运行控制台命令

PHP Version 5.4.6--pl0-gentoo

While I'm running this code:

$command = "/var/www/site/bin/wkhtmltopdf-amd64 /var/www/site/pdf_s.html
/var/www/site/test.pdf 2>&1";

passthru($command, $retval);
echo '<br />'.$command.'<br />';
var_dump($retval);

mostly I receive error #127, ones the output was:

Loading pages (1/6) [> ] 0% [======> ] 10% [=============================> ] 49% [============================================================] 100% QPainter::begin(): Returned false Error: Unable to write to destination /var/www/site/bin/wkhtmltopdf-amd64 /var/www/site/pdf_s.html /var/www/site/test.pdf 2>&1 int(1)

When I'm setting $command = '/bin/ls 2>&1'; it works 50/50, sometimes output is how it should be and sometimes it is error #127 again.

What is the magic? Why sometimes command executes fine and sometimes (mostly) I recieve error #127?? Why do this two commands work perfect in console but not in PHP?