简体   繁体   English

Laravel的Cron工作

[英]Cron job with Laravel

I am developing a Cron application using Laravel 4.2.11. 我正在使用Laravel 4.2.11开发Cron应用程序。 I used below command as Cron command. 我在下面的命令中使用Cron命令。

wget http://apiproducts.com/foysal/public/get_products

Where get_products is a route defined in routes.php . get_productsroutes.php文件中定义的路由。

But this command generates .txt file in server,like get_products.txt, get_products.1.txt, get_products.2.txt etc. 但是此命令会在服务器中生成.txt文件,例如get_products.txt,get_products.1.txt,get_products.2.txt等。

How can I get rid of this issue?? 我如何摆脱这个问题?

wget is a tool to retrieve something from the net (download), not just to send requests: wget是一种从网上检索内容(下载)的工具,而不仅仅是发送请求:

GNU Wget is a free software package for retrieving files using HTTP, HTTPS and FTP, the most widely-used Internet protocols. GNU Wget是一个免费软件包,可使用HTTP,HTTPS和FTP(最广泛使用的Internet协议)检索文件。

So, when calling this command, without any options, you will get the file with the response. 因此,在调用此命令时,如果没有任何选项,您将获得带有响应的文件。

If you are only after the ability to send a request, and you don't intend to fetch the page, you should probably rather look at cURL , which allows you to send requests via the terminal, and would work fine in a cron-job. 如果您只是想发送请求,而又不想获取页面,则可能应该看一下cURL ,它允许您通过终端发送请求,并且在cron-job中可以正常工作。

Your command would be changed to look like: 您的命令将更改为如下所示:

curl http://apiproducts.com/foysal/public/get_products

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM