I have a number of command line scripts in PHP that use exec() to perform tasks such as restarting services, loading MySQL timezone files, etc. While exec() itself does not
Redirecting stderr alone should not influence where processing takes place, just make sure not to add an &
. It should only run in the background if you redirect the output and make it run in the background.
Edit:
Cracked open cygwin, you need to redirect stderr for the first command, give this a try:
$command = 'mysql_tzinfo_to_sql /usr/share/zoneinfo 2> /dev/null | mysql mysql';
exec($command, $output, $result);