在HPANE(Hostinger -Cron Job)上运行Laravel任务计划

发布于 2025-01-22 09:28:40 字数 1441 浏览 2 评论 0 原文

运行调度程序我必须运行此命令:

* * * * * cd /home/u285707107/domains/dmn.com/ && php artisan schedule:run >> /dev/null 2>&1

但是在hpanel cron job-s中,我无法使用特殊字符,所以我创建 cron.sh file as 在Hostinger Cron Job I命令中,如何运行're =“ nofollow noreferrer”>在hostinger cron of in

#!/bin/sh
/home/u285707107/domains/dmn.com/ && php artisan schedule:run > /dev/null 2>&1

Commant I命令:

/bin/sh /home/u00000000/domains/dmn.com/public_html/dmn/app/Console/cron.sh

但是它不don' t工作:(

我的 kernel.php 文件是:

<?php

namespace App\Console;

use App\Models\Proview;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule){
        $schedule->call(function () {
            Proview::query()->update(['today' => 0]);
        })->everyMinute();
    }

    protected function commands(){
        $this->load(__DIR__.'/Commands');
        require base_path('routes/console.php');
    }
}

有人可以帮我吗?

as Running The Scheduler says I must run this Command:

* * * * * cd /home/u285707107/domains/dmn.com/ && php artisan schedule:run >> /dev/null 2>&1

but in hPanel Cron Job-s I can't use special characters, so I create cron.sh file as they say

#!/bin/sh
/home/u285707107/domains/dmn.com/ && php artisan schedule:run > /dev/null 2>&1

and in Hostinger Cron Job I run Command:

/bin/sh /home/u00000000/domains/dmn.com/public_html/dmn/app/Console/cron.sh

but it don't works : ( (

My Kernel.php file is:

<?php

namespace App\Console;

use App\Models\Proview;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule){
        $schedule->call(function () {
            Proview::query()->update(['today' => 0]);
        })->everyMinute();
    }

    protected function commands(){
        $this->load(__DIR__.'/Commands');
        require base_path('routes/console.php');
    }
}

can someone Help me ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

游魂 2025-01-29 09:28:40

您不需要bash文件,只需创建一个PHP脚本文件(.php),然后使用脚本“ PHP”类型设置CRON作业,

应该是:

<?php
chdir('/path-to-your-project'); // cd /path-to-your-project
exec('php artisan schedule:run >> /dev/null 2>&1'); // execute php artisan schedule:run >> /dev/null 2>&1 in powershell

对于Cron作业

You don't need bash file for this, just create a php script file (.php) and set the cron job using the type "php"

the script should be :

<?php
chdir('/path-to-your-project'); // cd /path-to-your-project
exec('php artisan schedule:run >> /dev/null 2>&1'); // execute php artisan schedule:run >> /dev/null 2>&1 in powershell

for the cron job

enter image description here

寄意 2025-01-29 09:28:40

只需用您的脚本替换以下脚本即可。

cron.sh

#!/bin/sh
cd /home/u285707107/domains/dmn.com && php artisan schedule:run >> /dev/null 2>&1

hostinger cron job

* * * * *   /bin/sh /home/u285707107/domains/dmn.com/public_html/dmn/app/Console/cron.sh

Just replace the below scripts with yours.

cron.sh

#!/bin/sh
cd /home/u285707107/domains/dmn.com && php artisan schedule:run >> /dev/null 2>&1

Hostinger Cron Job

* * * * *   /bin/sh /home/u285707107/domains/dmn.com/public_html/dmn/app/Console/cron.sh
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文