Cron jobs or scheduled tasks in Magento are enabled in order to perform some periodic operation on timely basis. Cron jobs need to be setup for following services and operations to work on specific date and time,

they are:

  • Re-indexing
  • Catalog price rules
  • Sending newsletters
  • Generating Google sitemaps
  • Customer notifications or alert messages
  • Auto update currency rates
  • Scheduled database log cleanups
  • Cache cleanups

In Magento 2, three cron jobs required to be run. As windows doesn’t have cron, we need to use a bat file and configure it to run as a scheduled task as shown below:

  1. First of all, find location of php.exe – Generally where Xampp is installed, it’s in Drive:\xampp\php e.g c:\xampp\php
  2. Go to a folder and create a file named mycron.bat
  3. Edit this file and paste 3 lines shown below:
  4. For example, mycron.bat looks as follows:
    C:\xampp\php\php.exe C:\xampp\htdocs\magento\bin\magento cron:run
    C:\xampp\php\php.exe C:\xampp\htdocs\magento\update\cron.php
    C:\xampp\php\php.exe C:\xampp\htdocs\magento\bin\magento setup:cron:run
    cron-commands

  5. Save the file, open command prompt and enter following command:
  6. Now click on Start –> Control Panel –> Administrative Tools –> Task Scheduler.
  7. process-set-up-magento-2-cron-in-xampp-for-windows

  8. Expand Task Schedule Library from the left hand column and click Magento.
  9. Select Cron from the middle pane, click properties from the right pane under selected items.
  10. Under Security Options, click the Change User or Group button.
  11. Now in the current window, enter System username in the object name box and click check names. Click OK to close the User window, and OK to close the Cron properties Window, and close Task Scheduler.
  12. Cron job setup is successful and it will run every 5 minutes.

Let me know if you suffering from any issues while setting up cron. I’ll be there to fix it for you.

[Total: 15   Average: 4.1/5]