我正在使用namecheap托管我的laravel应用程序,我也按照这里的所有说明https://www.namecheap.com/support/knowledgebase/article.aspx/9453/29/how-to-run-scripts-via-cron-jobs . 然后在cpanel的cron作业选项卡中设置我的cron作业后,我在我的电子邮件中收到通知但是artisan命令执行'nt seem to be executed as my database remains the same. i tried to echo out a value in the artisan command' s处理方法以进行测试但是没有任何输出,我仍然在我的电子邮件中收到通知,如此=> 'Running scheduled command: ' / opt / alt / php70 / usr / bin / php ' ' artisan ' deactivate:ads > ' /home/agrodqkc/applications/agroexpresslink/app/console/log.txt ' 2>&1 &'
这是我每分钟的cron命令=> / usr / local / bin / php / home / agrodqkc / applications / agroexpresslink / artisan schedule:run
我的kernel.php文件:
<?php
namespace mazee\Console;
use Illuminate\Console\Command;
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 = [
// Commands\Inspire::class,
Commands\maz::class,
Commands\deactivateads::class,
];
/**
* 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('maz:do')->everyMinute()->sendOutputTo(base_path().'/app/console/log.txt')->emailOutputTo('ewomaukah@yahoo.com');;
$schedule->command('deactivate:ads')->everyMinute()->sendOutputTo( base_path().'/app/console/log.txt');
}
}
1 回答
是否可以显示正在运行的cron命令,因为我认为cron作业设置不正确
如果您使用ssh访问您的服务器并输入crontab -e或者您可能有一个专用工具来设置cPanel中的cronjobs
CRON作业应设置如下:
上述命令将每分钟运行一次,并将搜索计划任务 .