Site icon MageComp Blog

How to Set up Magento 2 Cron in Xampp for Windows

How to Set up Magento 2 Cron in Xampp for Windows

How to Set up Magento 2 Cron in Xampp for Windows

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:

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:
php_path\php.exe magento_root\bin\magento cron:run
php_path\php.exe magento_root\update\cron.php
php_path\php.exe magento_root\bin\magento setup:cron:run

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

    1. Save the file, open command prompt and enter following command:
      schtasks /create /sc minute /mo 5 /tn Magento\Cron /tr path_t_bat_file\mycron.bat
    2. Now click on Start –> Control Panel –> Administrative Tools –> Task Scheduler.

  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.

Exit mobile version