اذهب إلى المحتوى
  • 0

Cron job قيد التشغيل لكن لا يتم تنفيذ السكربت

Mahmoud Alrashidi

السؤال

قمت برفع مشروعي على الخادم و قمت بتطبيق cron job التالي:

1 * * * * php /home/webminder/public_html/artisan schedule:run >> /dev/null 2>&1

لا أدري لماذا لا يتنفذ كل دقيقة؟ هل هناك خطأ ما؟ 

أيضاً هناك مُشكلة أخرى أن السكربت لا يتنفذ من خلال cron job لكن إذا قمت بتنفيذه يدوياً يشتغل بشكل عادي.

هذا ملف Kernel.php:

<?php

namespace App\Console;

use DB;
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\Reminder::class
    ];

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

    /**
     * Register the Closure based commands for the application.
     *
     * @return void
     */
    protected function commands()
    {
        require base_path('routes/console.php');
    }
}

و هذا ملف App\Console\Commands\Reminder.php:

<?php

namespace App\Console\Commands;

use DB;
use Illuminate\Console\Command;

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

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Renewal Server, Web Hosting and Domain Name';

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

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        DB::table('test')->insert(['name' => 'Testing']);
    }
}

لا أعرف مكان المشكلة.

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

  • 0
1 * * * *

يعني أن الأمر سيعمل في الدقيقة الأولى من كل ساعة ، استخدم:

* * * * *

لتشغيل الأمر كل دقيقة.

إذا كنت تقوم بتشغيل Laravel من حساب cPanel ، فيمكنك محاولة تحديد مسار PHP الكامل كالتالي:

* * * * * /usr/local/bin/php /home/webminder/public_html/artisan schedule:run >> /dev/null 2>&1
رابط هذا التعليق
شارك على الشبكات الإجتماعية

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...