Jump to content

How to suppress output from PHP on CLI while deprecated warnings are printed


Recommended Posts

We already know why there are deprecated PHP warnings while running an old piece of code under PHP 8.0

The PHP code with legacy issues will be updated by someone new about to be hired.

For now, we just want php being run out of a cron to use the settings we have in php.ini:

error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT

This isn't working.  Every time the cron runs, it will email the deprecated warning.

* * * * * php /usr/local/cron.php >> /usr/local/cron.log

Someone claimed in an online forum that for PHP run at the command line,
as it would be for a cron, it doesn't have this control over error reporting.
I don't know if that is accurate.

As a solution for the time being, I've added  2>&1 >> /dev/null
to the end of the cron line.  But it would be better to use the php error_reporting
preference if we could.

 

 

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.