0

I am trying to remove the cron jobs in Magento 2. In SSH running

crontab -l

I get the following output.

enter image description here

From Magento docs I found out that I need to run the command

php bin/magento cron:remove

to disable cron but it is not working. After running this command when I run "crontab -l" I still see the cron jobs code between #~ MAGENTO START and #~MAGENTO END.

I also checked the cron_schedule table to be sure If the cron was running and yes this table is still getting populated with new rows. I have read somewhere that I need to remove cron only before uninstalling Magento but it is a staging environment and I do not need cron jobs here.

What I am doing wrong as I found this command in Magento docs to remove cron?

1

I see you're using Cpanel, are they reflected in the Cpanel backend under Scheduled Tasks for the root user? If so you should be able to remove it from there.

Otherwise, you can just remove it from the cron file directly via SSH by running crontab -e and commenting the mage cron lines with a # character.

If you opt for crontab -e by default it will open VIM as the text editor. If you click i key on your keyboard it should go into insert mode (it will say insert in the bottom left) and you can comment the cron lines. Then to exit, you click esc to leave insert mode, :wq to save and quit.

| improve this answer | |
  • I used crontab -e and commented those lines for now. I also checked in Cpanel cron jobs were not added there. So why I am not able to remove cron jobs using command "php bin/magento cron:remove" – Rajeev Singh Dec 13 '19 at 6:22
  • 1
    Not 100% sure, but I'd say if it's failing silently it's most likely trying to edit a different filesystem user crontab. If you really want to find out you can edit the core function to echo the user/crontab its trying to edit. github.com/magento/magento2/blob/2.4-develop/lib/internal/… – Sam Dec 13 '19 at 18:06

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.