laravel cron工作不起作用
it1352
帮助1人
问题说明
我的laravel cron作业无法自动运行.我对其进行了测试,并且似乎可以正常工作,当我使用php artisan checkCommissions:check_commissions时,它可以完美地运行我的任务.所以我认为问题出在我用cpanel编写的命令中,所以有什么帮助吗?
my laravel cron job it does not work automatically. I test it and it seems to work, when I php artisan checkCommissions:check_commissions it runs my task perfectly. so I think the problem is with the command I wrote in cpanel so any help ?
app \ Console \ Commands \ CheckCommissions.php:
app\Console\Commands\CheckCommissions.php:
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\User;
use App\Models\Setting;
use App\Models\Commission;
class checkCommissions extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'checkCommissions:check_commissions';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check users counters and give them commissions';
/**
* Create a new command instance.
*
* @return void
*/
public function __construct()
{
parent::__construct();
}
/**
* Execute the console command.
*
* @return mixed
*/
public function handle()
{
$maxout = Setting::where('name', 'maxout')->first();
if (!is_null($maxout)) {
$maxout = $maxout->value;
}
if (is_null($maxout) || !is_numeric($maxout) || $maxout < 0) {
$maxout = 0;
}
$commission = Setting::where('name', 'commission')->first();
if (!is_null($commission)) {
$commission = $commission->value;
}
if (is_null($commission) || !is_numeric($commission) || $commission < 0) {
$commission = 0;
}
$users = User::all();
foreach ($users as $user) {
if ($user->counter_right >= $maxout && $user->counter_left >= $maxout) {
$num = $maxout;
$update_counters = User::where('id', $user->id)->update(['counter_left' => 0, 'counter_right' => 0]);
} else {
if ($user->counter_right >= $user->counter_left) {
$num = $user->counter_left;
} else {
$num = $user->counter_right;
}
$update_counters = User::where('id', $user->id)->update(['counter_left' => $user->counter_left - $num, 'counter_right' => $user->counter_right - $num]);
}
if($num > 0) {
$money = $num * ($commission / 2);
$update_user = User::where('id', $user->id)->update(['money' => $user->money $money]);
Commission::insert(['user_id' => $user->id, 'money' => $money]);
}
}
}
}
app \ Console \ kernel.php:
app\Console\kernel.php:
<?php
namespace App\Console;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
* @var array
*/
protected $commands = [
'\App\Console\Commands\checkCommissions',
];
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @return void
*/
protected function schedule(Schedule $schedule)
{
// $schedule->command('inspire')
// ->hourly();
$schedule->command('checkCommissions:check_commissions')
->everyMinute(); //
}
/**
* Register the Closure based commands for the application.
*
* @return void
*/
protected function commands()
{
require base_path('routes/console.php');
}
}
以及Cpanel中的命令:
and the command in Cpanel:
分钟小时月份月份工作日命令操作
Minute Hour Day Month Weekday Command Actions
0 0 * * * /usr/local/bin/php /home/gridtumg/public_html/tree/local/artisan checkCommissions:check_commissions >> /dev/null 2>&1
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcffhaj
系列文章
更多
同类精品
更多
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20