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

1.Find the location of php.exe – In you have Wamp installed, it’s in Drive:\wamp\bin\php\php5.6.25 e.g c:\wamp\bin\php\php5.6.25
2.Go to a folder and create a file named yourcron.bat
3.Edit this file and paste 3 lines shown below:
in the following file i have added to cron job for re-indexing and cache

C:\wamp\bin\php\php5.6.25\php.exe C:\wamp\www\magento2\bin\magento cron:run
C:\wamp\bin\php\php5.6.25\php.exe C:\wamp\www\magento2\update\cron.php
C:\wamp\bin\php\php5.6.25\php.exe C:\wamp\www\magento2\bin\magento setup:cron:run
C:\wamp\bin\php\php5.6.25\php.exe C:\wamp\www\magento2\bin/magento indexer:reindex
C:\wamp\bin\php\php5.6.25\php.exe C:\wamp\www\magento2\bin/magento cache:flush

4. Save the file, open command prompt and enter following command:

schtasks /create /sc minute /mo 5 /tn Magento\Cron /tr C:\wamp\bin\php\php5.6.25\yourcron.bat

5. Now click on Start –> Control Panel –> Administrative Tools –> Task Scheduler
6. Expand Task Schedule Library from the left hand column and click Magento.
7. Select Cron from the middle pane, click properties from the right pane under selected items.
8. Under Security Options, click the Change User or Group button.
9. 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.
10. Cron job setup is successful and it will run every 5 minutes.


Categories: Magento2

0 Comments

Leave a Reply

Avatar placeholder

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