0

I have a host running centOS. My website is based on Magento and it is live.

I have created a module that runs a cron job every minute.

My question is: I'm running my localhost on windows (wampserver 2.0). Before uploading my module on live host i want to test it on my local host. Is it possible to test my cron job running module on windows?

user487772
  • 8,800
  • 5
  • 47
  • 72
Hemen Ashodia
  • 202
  • 2
  • 4
  • 21

6 Answers6

6

By saying that your module "runs" a cron job you probably mean that is adds a cron job. For testing it you don't need a cron to run on your windows localhost. You can trigger all Magneto cron jobs manually by running cron.php in from the root directory of your Magento installation. You can do it from a browser like this http://localhost/magento_dir/cron.php.

user487772
  • 8,800
  • 5
  • 47
  • 72
1

You have at least 2 options:

  1. You can call the scripts with Windows Scheduler.
  2. You can install Cygwin and define the cron tasks as in Linux. More information here: How do you run a crontab in Cygwin on Windows?
Community
  • 1
  • 1
Jordan Jambazov
  • 3,460
  • 1
  • 19
  • 40
  • Could you provide more in deph steps with Step 1 as i have done that with Windows Shceduler but i don't know what it is actually doing and Magento doesn't seem to recognize any cron tasks happening – Sebastian May 09 '18 at 02:37
1

Magento 2.0.2 Open Command Prompt

Write

cd c:\xampp\htdocs\magento202\bin
php magento cron:run
php magento cron:run
cd C:\xampp\htdocs\magento202\update
php cron.php
cd c:\xampp\htdocs\magento202\bin
php magento setup:cron:run

replace the directory ‘magento202’ with yours

Tunaki
  • 132,869
  • 46
  • 340
  • 423
George-151
  • 11
  • 1
  • how to use the magento command on windows, windows doesn't recognize it, the official Magento site just refers to Linux for using the Magento Commands – Sebastian May 09 '18 at 02:36
0

You can use schtasks.exe to create a new scheduled task to run as per your need.

schtasks /create /sc minute /mo 1 /tn "Cron" /tr "php -f C:\wamp\www\pro\run.php"

You can find more info about the commands and the usage in the below link of my blog.

http://purusothaman.me/computers/running-cron-in-windows/

Purus
  • 5,701
  • 9
  • 50
  • 89
0

If using Windows 2008 and later enter the Management MMC and access Task Scheduler under Configuration. For 1.8 Mage must add -mdefault 1 to your statement. There are changes in the cron file.

0

"You can do it from a browser like this http://localhost/magento_dir/cron.php" > you will get Acces denied -> go edit .htaccess and comment lines

###########################################
## Deny access to cron.php
##   <Files cron.php>

############################################
## uncomment next lines to enable cron access with base HTTP authorization
## http://httpd.apache.org/docs/2.2/howto/auth.html
##
## Warning: .htpasswd file should be placed somewhere not accessible from the web.
## This is so that folks cannot download the password file.
## For example, if your documents are served out of /usr/local/apache/htdocs
## you might want to put the password file(s) in /usr/local/apache/.
#AuthName "Cron auth"
#AuthUserFile ../.htpasswd
#AuthType basic
#Require valid-user
############################################
##     Order allow,deny
##   Deny from all
##</Files>