Laravel - 如何自动每天调用一次方法

时间:2021-02-03 00:00:04

I am using Laravel v. 4.1 on a website. Every once in a month, I need a specific method to be called automatically for a monthly payment with Moneris. I already tested my API and it's working pretty fine. But how to call this method once a day to check if users have to pay for their monthly payment? Is it possible to do that and to call it without having a HTTP Request?

我在网站上使用Laravel v.4.1。每隔一个月,我需要一个特定的方法来自动调用Moneris每月付款。我已经测试了我的API,它的工作非常好。但是如何每天调用一次此方法来检查用户是否需要支付每月付款?是否可以这样做,并在没有HTTP请求的情况下调用它?

Thank you!

1 个解决方案

#1


You need to build an artisan command and then call it in your crontab:

您需要构建一个artisan命令,然后在您的crontab中调用它:

* 0 * * * php /usr/share/nginx/html/example.com/artisan tns:delete-old-jobs --env=production >/dev/null 2>$1

Have the artisan command trigger your API method.

让artisan命令触发您的API方法。

#1


You need to build an artisan command and then call it in your crontab:

您需要构建一个artisan命令,然后在您的crontab中调用它:

* 0 * * * php /usr/share/nginx/html/example.com/artisan tns:delete-old-jobs --env=production >/dev/null 2>$1

Have the artisan command trigger your API method.

让artisan命令触发您的API方法。