Magento – escapeshellarg() has been disabled – cronjob – Magento 2

croncrontabmagento-2.1

I get this error after installing Magento 2 and enabling the cronjob.
The error appears in the email/logfile of the following cronjob:

/usr/local/bin/php -f /home/craftweb/domains/craftseurope.eu/public_html/bin/magento cron:run

*[Exception]
Warning: escapeshellarg() has been disabled for security reasons in /home/craftweb/domains/craftseurope.eu/public_html/vendor/magento/framework/Shell/CommandRenderer.php on line 19

cron:run [–group="…"] [–bootstrap="…"]*

Can I deny this one or is there a fix? I don't know if it now works correctly.
Maybe someone can give me those insights.

Best Answer

Make your own escapeshellarg:

At the end of CommandRenderer.php file add a function:

public function my_escapeshellarg($input)
{
    $input = str_replace('\'','\\\'', $input);
    return '\''.$input.'\'';
}

and substitute the line above with

$arguments = array_map('my_escapeshellarg', $arguments);

Or more your store to another host different than mine

Related Topic