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 ?


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.

| improve this answer | |
  • you are genius bro...let me check with hosting provider. – Atul Sep 1 '16 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 '16 at 12:58
  • @Atul sweet glad you fixed your issue – Raphael at Digital Pianism Sep 1 '16 at 12:59
  • thx you gave me the direction.. :) – Atul Sep 1 '16 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? – Els den Iep Feb 7 '18 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.

| improve this answer | |
  • 1
    Or define the config value directly (no need to duplicate your php.ini): php -d disable_functions= bin/magento cron:run – Danny Nimmo Feb 27 '18 at 22:59
  • That's indeed easier. Thanks for the tip! – Jan Sierens Feb 28 '18 at 8:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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