Magento2 Cron Error – Exec Function is Disabled

cronerrormagento2

while trying to run Cron through Command Prompt getting below error –

Command – php bin/magento cron:run

Getting Error –

[Magento\Framework\Exception\LocalizedException]
exec function is disabled.

Can you plz let me know how to enable 'exec' function and run default group name cron properly ?

Best Answer

The error comes from /lib/internal/Magento/Framework/Shell.php :

    $disabled = explode(',', ini_get('disable_functions'));
    if (in_array('exec', $disabled)) {
        throw new Exception("exec function is disabled.");
    }
    exec($command, $output, $exitCode);

Basically to be able to execute the command, Magento needs to run the PHP exec function.

Some hosting providers disable this function for security reason and in your case that's what the problem is.

I suggest you contact your hosting provider in order to re enable the exec method for your site.