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

Command - php bin/magento cron:run

Getting Error -

exec function is disabled.

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

2 Answers 2


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.

  • you are genius bro...let me check with hosting provider.
    – Atul
    Sep 1, 2016 at 12:03
  • Here is the host provider reply - when running php via apache it differs from when running via cron . So in my case this command works - Go to your magento 2 root then run -> php -c ~/php.ini bin/magento cron:run
    – Atul
    Sep 1, 2016 at 12:58
  • @Atul sweet glad you fixed your issue Sep 1, 2016 at 12:59
  • thx you gave me the direction.. :)
    – Atul
    Sep 1, 2016 at 13:00
  • My hosting provider does not want to take the risk and refuses to enable php exec function. Is there any other way I can perform my cron:run? Feb 7, 2018 at 14:18

Use a custom php.ini for the cron jobs:

/usr/local/bin/php -c customphp.ini bin/magento cron:run

Just take a copy of the original php.ini. Search for disable_functions and remove exec from the list.

There is no need to open exec for the web application.

  • 4
    Or define the config value directly (no need to duplicate your php.ini): php -d disable_functions= bin/magento cron:run Feb 27, 2018 at 22:59
  • That's indeed easier. Thanks for the tip! Feb 28, 2018 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.