[英]Testing magento module running cron job on windows/wamp
我有一台运行centOS的主机。 我的网站基于Magento,并且已经上线。
我创建了一个模块,每分钟运行一次cron作业。
我的问题是:我正在Windows(wampserver 2.0)上运行本地主机。 在将模块上传到实时主机上之前,我想在本地主机上对其进行测试。 是否可以在Windows上测试我的cron作业运行模块?
通过说模块“运行” cron作业,您可能意味着添加了cron作业。 为了进行测试,您不需要在Windows本地主机上运行cron。 您可以通过从Magento安装的根目录中运行cron.php
来手动触发所有Magneto cron作业。 您可以从类似http://localhost/magento_dir/cron.php
的浏览器中进行操作。
您至少有2个选择:
Magento 2.0.2打开命令提示符
写
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
用您的目录替换目录“ magento202”
您可以使用schtasks.exe创建新的计划任务以根据需要运行。
schtasks /create /sc minute /mo 1 /tn "Cron" /tr "php -f C:\wamp\www\pro\run.php"
您可以在我博客的以下链接中找到有关命令和用法的更多信息。
如果使用Windows 2008及更高版本,请输入管理MMC并在“配置”下访问“任务计划程序”。 对于1.8 Mage,必须在您的语句中添加-mdefault 1。 cron文件中有更改。
“您可以从类似http://localhost/magento_dir/cron.php这样的浏览器中完成此操作>>您将被拒绝Acces->编辑.htaccess和注释行
###########################################
## 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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.