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:
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

    1. Save the file, open command prompt and enter following command:
    2. Now click on Start –> Control Panel –> Administrative Tools –> Task Scheduler.

process-set-up-magento-2-cron-in-xampp-for-windows

  1. Expand Task Schedule Library from the left hand column and click Magento.
  2. Select Cron from the middle pane, click properties from the right pane under selected items.
  3. Under Security Options, click the Change User or Group button.
  4. 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.
  5. 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.

Click to rate this post!
[Total: 16 Average: 4.1]