我有一個 Laravel 專案 v8,我已經建立了一個用於資料庫備份的 cron 作業
它每分鐘都在工作,但當我指定每天的時間時,它就不起作用。
專案時區是“亞洲/加爾各答”,我的 GoDaddy 共用伺服器時區是 UTC。
核心.php
<?php namespace App\Console; use Illuminate\Console\Scheduling\Schedule; use Illuminate\Foundation\Console\Kernel as ConsoleKernel; class Kernel extends ConsoleKernel { /** * Define the application's command schedule. * * @param \Illuminate\Console\Scheduling\Schedule $schedule * @return void */ protected function schedule(Schedule $schedule) { // $schedule->command('backup:clean')->everyMinute(); $schedule->command('backup:run')->cron('51 3 * * *'); } /** * Register the commands for the application. * * @return void */ protected function commands() { $this->load(__DIR__.'/Commands'); require base_path('routes/console.php'); } }
我在 Cpanel 上的 cronjob。
取代您的kernel.php
在此之後,在 Cpanel 上設定 cronjob 以及您要執行的時間
檢查 cpanel 中的給定時間,cron 一定會工作
你可以這樣執行 cron: