I have statusUpdate.php file in the xampp\htdocs\project\app\Console\Commands folder.

statusUpdate.php :

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use DB;


class statusUpdate extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'status:update';

/**
 * The console command description.
 *
 * @var string
 */
protected $description = 'Update Job status daily';

/**
 * Create a new command instance.
 *
 * @return void
 */
public function __construct()
{
    parent::__construct();
}

/**
 * Execute the console command.
 *
 * @return mixed
 */
public function handle()
{
    $affected = DB::table('jobs')->update(array('status' => 1));
}
}

它由以下Laravel官方文件创建.

以下是karnel.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\statusUpdate::class,
];

/**
 * Define the application's command schedule.
 *
 * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
 * @return void
 */
protected function schedule(Schedule $schedule)
{
    $schedule->command('status:update')
             ->everyFiveMinutes();
}
}

然后我就跑了

php artisan schedule:在windows 7上使用CMD运行命令.

Now it is working fine(in local server). My jobs table status field is updated properly by 1.

But when I was deployed this project on the shared hosting and added a CRON command for my server in cPanel:

Cron job command is like this : php /path/to/artisan schedule:run 1>> /dev/null 2>&1

现在,在这种情况下,命令不起作用&amp;这就是问题所在.我该怎么解决呢?

推荐答案

井.我按照你所说的给你答案.

Cron作业(job)命令如下:php /path/to/artisan schedule:run 1>> /dev/null 2>&1

路径应该是在服务器中定位artisan文件.这样地:

假设artisan文件位置为/var/www/artisan,那么简单的答案是:

php /var/www/artisan schedule:run 1>> /dev/null 2>&1

Just check if that works. Thank You!

UPDATE:

http://i.imgur.com/wVAWAHK.png

This is how it should look like.

Laravel相关问答推荐

在没有lang/*.json文件的情况下在Laravel项目中实现多语言支持

运行NPM Prod时出现VUE问题

如何解决此 Backblaze B2 S3 兼容 API 错误?

V-icon 在 Vuetify 3 中不显示图标

验证判断请求的值是否存在于另一个表 Laravel 9 中

Laravel created_at 返回对象代替数据库中的日期格式?

laravel render() 方法有什么用?

Laravel:如何在 laravel 查询生成器中使用派生表/子查询

使用 Eloquent 的 Laravel 块方法

Laravel 5.1 如何在Blade 文件上使用 {{ old('') }} 助手进行无线电输入

.gitignore 不忽略文件夹

带有 Laravel Passport 的 SSO

Laravel 5.5 类型错误:传递给 Illuminate\Auth\EloquentUserProvider::validateCredentials() 的参数 1 必须是实例

如何使用外部图像生成 html div 的 screenshot截图?

当表中不存在列时如何将 paginate() 与 having() 子句一起使用

无法打开流:没有这样的文件或目录(Laravel)

Laravel 更新语法 - 使用数组更新记录

我在哪里放置可以显示 Flash 消息的 Laravel 4 辅助函数?

Laravel - 使用 Eloquent 查询构建器在 Select 中添加自定义列

如何在脚本文件中使用 Laravel Blade?