1

This question already has an answer here:

How can I configure the Magento 2 cron job in Wamp Windows? For upgrade Magento 2 asking cron in Wamp localhost.

marked as duplicate by liyakat, 7ochem, Dhiren Vasoya, Priyank, sv3n Apr 18 '18 at 22:31

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • please check my answer. Hope that'll help you. – Emipro Technologies Pvt. Ltd. Apr 18 '18 at 6:56
  • @MagenX I am using wamp – zus Apr 18 '18 at 7:46
  • i am using wamp. read my post carefully. FYI Moderator – zus Apr 18 '18 at 7:48
  • please use search, wamp and windows are the same stack... – MagenX Apr 18 '18 at 7:51
3

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.

Hope this will help you.

  • @zus check 4th step and replace 1 instead of 5 and your work done. – Mayur Apr 18 '18 at 11:09
  • Above one create command right, how can i edit the min. – zus Apr 18 '18 at 11:15
  • schtasks /create /sc minute /mo 1 /tn Magento\Cron /tr C:\wamp\bin\php\php5.6.25\yourcron.bat – Mayur Apr 18 '18 at 11:20
  • May i know why am getting this error while running cron, snag.gy/VAPJyG.jpg – zus Apr 19 '18 at 4:17
0
  1. Create a cron.php file (the code you want to execute at a regular interval)

  2. Create a CRON.BAT file, copy and past the below code in the file D:\xampp\php\php.exe D:\xampp\htdocs\Application\cron.php

The path I have written is according to my xampp and cron.php file, update the path of files according to your system directory

  1. To schedule a task Click on start > All Programs > Accessories > System Tools > Scheduled Tasks

Or you can go directly to Control Panel > Scheduled Tasks

Right click in the folder New > Schedule Task

Give appropriate name to the Task. In the RUN text field… Type the complete path of the CRON.BAT file in my case it is D:\xampp\htdocs\Application\CRON.BAT

Set the schedule of the job, you can use advanced button if required.

I hope this helps.

Not the answer you're looking for? Browse other questions tagged or ask your own question.