Suppressing output from exec() calls in PHP

后端 未结 4 2130
灰色年华
灰色年华 2020-12-15 17:33

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

4条回答
  •  青春惊慌失措
    2020-12-15 17:53

    Just redirect stderr to /dev/null

    $command = 'mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql 2>/dev/null';
    

    or to stdout

    $command = 'mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql mysql 2>&1';
    

提交回复
热议问题