Unlike in Magento 1, cron performs critically important tasks in Magento 2. In the native installation there are 26 modules that use cron for 53 different jobs. You can get acquainted with the full list of modules below on the text.
Practically, all reindex processes work in cron process. Newsletters, product alerts, page cache etc
Moreover, most of the third-party extensions use cron and some extensions simply do not run if the cron is not configured or operates in the wrong way.
How to determine cron not working?
a) To install Magento 2 Cron Scheduler extension
Nowadays, there are many extensions that perform complex checking and visualization of cron task performance. You can easily find them with the inquiry “magento 2 cron scheduler extension” or “magento 2 cron module”
b) To check directly in the database In case you do not want to install an additional extension, it is enough for you to open up DB (via phpMyAdmin, for example) and run a simple SQL query:
SELECT MAX(executed_at) FROM cron_schedule
If cron works correctly, you get almost current time (max 5 min deviation)
Another useful SQL query that returns the list of log errors:
SELECT job_code, messages FROM cron_schedule WHERE messages IS NOT NULL
Cron job is not working. What should I do?
In Magento 2 the cronjob performance is related to the command
Connect via ssh and run the command
crontab -l to obtain the list of active cronjobs. After your running the command
crontab -l > crontab.cfg you will record the current configuration to a file for the following editing. The command
crontab crontab.cfg, vice versa, installs the configuration from the file.
Also, you can set up cron via Cpanel, the same configurations, however, via web interface (Cpanel > Cron Jobs or Cpanel > Scheduled Tasks)
If you already have cronjob or you only have to add it , we recommend to use the following command:
* * * * * php -f [store root]/bin/magento cron:run >> [store root]/var/log/magento.cron.log 2>&1;
[store root] is the root directory with installed Magento.
This command is slightly different from a command given in Magento 2 manuals, however brings the variety of unquestionable advantages: ANY error and any successful performance will be recorded in a log file.
After new cronjob configuring, within the next minute, the log file store
[root]/var/log/magento.cron.log with the error text or successful performance notification “Ran jobs by schedule.” will appear.
If the file does not occur within next 1 minute, it means the wrong path to the root directory or no permissions to write to the directory
Cron is essentially important and that is why you should pay so much attention to it and be sure that it operates correctly. Cron errors checking is implemented in our Stability Suite for Magento 2, that will also notify you about the errors.
The list of Magento 2 extensions that use cron: NewRelicReporting, ProductAlert, CatalogRule, Integration, Backup, Sales, Persistent, Newsletter, Directory, Analytics, Shipping, Security, Catalog, Captcha, Backend, Sitemap, Tax, Customer, Paypal, Indexer.
Mirasvit extensions that use cron: Search, SearchSphinx, Misspell, Stability, Rewards, Affiliate, Email, Report, Helpdesk, RMA, StoreCredit.