title: Suppressing output from exec() calls in PHP
body: <p>I have a number of command line scripts in PHP that use <a href="http://us3.php.net/manual/en/function.exec.php" rel="noreferrer">exec()</a> to perform tasks such as restarting services, loading MySQL timezone files, etc.  While exec() itself does not output anything to the screen, some of the commands I am running are forcing output that I can't seem to suppress (even with ob_start()/ob_end_clean()).  For example, the following would load timezone files into MySQL.  We run this periodically to make sure MySQLs timezone data is up to date:</p>
  
  <pre><code> $command = 'mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql';
   exec($command, $output, $result);
  </code></pre>
  
  <p>In this example, I would expect all output from the command to be written into $output, but I still get the following output forced to the screen:</p>
  
  <pre><code>Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh87' as time zone. Skipping it.
  Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh88' as time zone. Skipping it.
  Warning: Unable to load '/usr/share/zoneinfo/Asia/Riyadh89' as time zone. Skipping it.
  ...
  </code></pre>
  
  <p>Is there any way to suppress this output?  Redirecting to /dev/null is not ideal as that would cause PHP to continue processing without waiting for the command to complete.</p>
  
  <p>Thanks in advance,<br>
  ~ JamesArmes</p>