magento2-cron setup

March 4, 2022 . 1 MIN READ

To create the Commerce crontab:

  1. Log in as, or switch to, the file system owner.
  2. Change to your Magento installation directory.
  1. Enter the following command:
bin/magento cron:install [–force]

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 your crontab.
  • magento cron:install –force has no effect on any cron jobs outside the Magento comments.

To view the crontab, enter the following command as the file system owner:

crontab -l

A sample follows:

#~ MAGENTO START c5f9e5ed71cceaabc4d4fd9b3e827a2b* * * * * /usr/bin/php /var/www/html/magento2/bin/magento cron:run 2>&1 | grep -v “Ran jobs by schedule” >> /var/www/html/magento2/var/log/magento.cron.log#~ MAGENTO END c5f9e5ed71cceaabc4d4fd9b3e827a2b

Reference: https://devdocs.magento.com/guides/v2.4/config-guide/cli/config-cli-subcommands-cron.html#create-or-remove-the-magento-crontab

Leave a Reply

Your email address will not be published. Required fields are marked *