Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Users cannot use WP-CLI in cron

Discussion in 'General Discussion' started by VM Creativo, Dec 8, 2018.

  1. VM Creativo

    VM Creativo Registered

    Joined:
    Dec 8, 2018
    Messages:
    3
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    Hello, I installed WP-CLI from root, I can use it from a user's terminal without problems, but when I want to use it in CRON, I get the following errors:

    Code:
    PHP Warning:  Use of undefined constant STDOUT - assumed 'STDOUT' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/utils.php on line 995
    PHP Warning:  Use of undefined constant STDERR - assumed 'STDERR' (this will throw an Error in a future version of PHP) in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Quiet.php on line 43
    PHP Warning:  fwrite() expects parameter 1 to be resource, string given in phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Loggers/Base.php on line 61
    Content-type: text/html; charset=UTF-8
    If I set up the same cron with the root account (with crontab -e) it works fine:
    Code:
    * * * * * /usr/local/bin/wp --allow-root --version
    But using CPanel cron jobs it fails
    Code:
    /usr/local/bin/wp --version
    ----------------

    In WP-Cli documentation they say:

    The STDOUT constant is defined by the PHP CLI. If you receive an error notice that STDOUT is missing, it’s likely because you’re not running WP-CLI by PHP CLI. Please review your server configuration accordingly.

    ----------------

    I don't know where to look to solve this problem.
     
  2. VM Creativo

    VM Creativo Registered

    Joined:
    Dec 8, 2018
    Messages:
    3
    Likes Received:
    3
    Trophy Points:
    3
    Location:
    Spain
    cPanel Access Level:
    Root Administrator
    I answer myself, to use wp-cli in cron to run wp-cron:

    Code:
    cd ~/public_html; /usr/local/bin/php /usr/local/bin/wp cron event run --due-now --quiet
     
    baronn and cPanelLauren like this.
  3. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    6,206
    Likes Received:
    478
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @VM Creativo

    I'm really glad to see you were able to find the resolution for your issue and thank you very much for adding what solved it for you.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice