Steps to Create the crontab :
First, Open the Terminal and log in with the root user. After that go to Magento Root Path then run the below command:
1 | bin/magento cron:install |
Output:
Crontab is created and saved.
1 | bin/magento cron:install —force |
Crontab is created and saved
NOTE: Use –force to rewrite an existing Magento crontab.
- magento cron:install does not rewrite an existing crontab inside #~ MAGENTO START and #~ MAGENTO END comments in crontab.
- magento cron:install –force does not affect any cron jobs outside Magento comments.
To check crontab List, run the below command:
1 | crontab –l |
Output:
Steps to Run cron from the command line
Log in with the root user in the terminal. Go to Magento Root Path After running the below command:
1 | bin/magento cron:run |
Output:
Ran jobs by schedule.
where –group defines the cron group to run (eliminate this alternative if you want to run cron for all groups)
1 | bin/magento cron:run [—group=“<cron group name>”] |
To run the indexing cron job, enter:
1 | bin/magento cron:run —group index |
To run the default cron job, enter:
1 | bin/magento cron:run —group default |
Steps to Remove the Magento crontab:
First Open Terminal and login with the root user and go to Magento Root Path After running the below command :
1 | bin/magento cron:remove |
Output:
Magento cron tasks have been removed