Create or remove the Commerce crontab
This section discusses how to create or remove your Commerce crontab (that is, the configuration for Commerce cron jobs).
The crontab is the configuration used to run cron jobs.
The Commerce application uses cron tasks that can run with different configurations. The PHP command-line configuration controls the general cron job that reindexes indexers, generates e-mails, generates the sitemap, and so on.
- To avoid issues during installation and upgrade, we strongly recommend you apply the same PHP settings to both the PHP command-line configuration and to the PHP web server plug-in’s configuration. For more information, see Required PHP settings.
- In a multi-node system, crontab can run on only one node. This applies to you only if you set up more than one webnode for reasons related to performance or scalability.
Create the Commerce crontab
Starting with version 2.2, Commerce creates a crontab for you. We add the Commerce crontab to any configured crontab for the Commerce file system owner. In other words, if you already set up crontabs for other extensions or applications, we add the Commerce crontab to it.
The Commerce crontab is inside #~ MAGENTO START
and #~ MAGENTO END
comments in your crontab.
To create the Commerce crontab:
-
Log in as, or switch to, the file system owner.
-
Change to your Commerce installation directory.
-
Enter the following command:
Use --force
to rewrite an existing crontab.
magento cron:install
does not rewrite an existing crontab inside#~ MAGENTO START
and#~ MAGENTO END
comments in your crontab.magento cron:install --force
has no effect on any cron jobs outside the Commerce comments.
To view the crontab, enter the following command as the file system owner:
A sample follows:
update/cron.php
file has been removed in Commerce 2.4.0, if this file exists on your installation, it can be safely removed.update/cron.php
and bin/magento setup:cron:run
should also be removed from the crontab’Remove the Commerce crontab
You should remove the Commerce crontab only before uninstalling the Commerce application.
To remove the Commerce crontab:
-
Log in as or switch to the file system owner.
-
Change to the Commerce installation directory.
-
Enter the following command:
#~ MAGENTO START
and #~ MAGENTO END
comments in your crontab.Run cron from the command line
Command options:
where --group
specifies the cron group to run (omit this option to run cron for all groups)
To run the indexing cron job, enter:
To run the default cron job, enter:
To set up custom cron jobs and groups, see Configure custom cron jobs and cron groups.
scheduled_at
time for every task.Logging
All cron
job information has moved from system.log
into a separate cron.log
.
By default, the cron information can be found at <install_directory>/var/log/cron.log
.
All exceptions from cron jobs are logged by \Magento\Cron\Observer\ProcessCronQueueObserver::execute
.
In addition to being logged in cron.log
:
-
Failed jobs with
ERROR
andMISSED
statuses are logged to the<install_directory>/var/log/support_report.log
. -
Jobs with an
ERROR
status are always logged asCRITICAL
in<install_directory>/var/log/exception.log
. -
Jobs with a
MISSED
status are logged asINFO
in the<install_directory>/var/log/debug.log
directory (developer mode only).
cron_schedule
table in the Commerce database. The table provides a history of cron jobs, including:- Job ID and code
- Status
- Created date
- Scheduled date
- Executed date
- Finished date
SELECT * from cron_schedule;
.