[英]How to schedule a yearly cron job for a Laravel app on Linux AMI?
I'm trying to set up a cron job for the 1st of January on my AWS EC2 instance for ec2-user
. 我正在尝试在
ec2-user
AWS EC2实例上为1月1日设置cron作业。 When I do crontab -u ec2-user -l
, it shows the following output: 当我执行
crontab -u ec2-user -l
,它显示以下输出:
* * * * * usr/bin/php /var/www/html/artisan schedule:run >> /dev/null 2>&1
But even though the following was set up in Kernel.php
, the job never fired: 但是,即使在
Kernel.php
中设置了以下Kernel.php
,该工作也从未触发:
protected $commands = [
// Commands\Inspire::class,
Commands\TestYearlyJob::class,
];
protected function schedule(Schedule $schedule)
{
$schedule->command('table:test-yearly-job')->cron('0 0 1 1 *')
->timezone('Europe/London')
->appendOutputTo('../taskscheduler.log');
}
The command itself runs from Artisan (I've double checked), so its logic is fine. 该命令本身是从Artisan运行的(我已经仔细检查过),因此它的逻辑很好。
I'm wondering if there is a way to do it with the ->yearly()->at()
scheduling option? 我想知道是否可以通过
->yearly()->at()
调度选项来实现? Or perhaps with a closure
truth test? 还是通过
closure
真实性测试? But I'm not sure what to put in there for a when()
statement. 但是我不确定在
when()
语句中该放什么。 Please help. 请帮忙。
I noticed cron
function has 6 stars. 我注意到
cron
函数有6星。 Try ->cron('0 0 1 1 * *')
. 尝试
->cron('0 0 1 1 * *')
。 Also yearly
has the same expression, so you can try either this command(..)->yearly()->timezone(..)
而且
yearly
具有相同的表达式,因此您可以尝试使用以下command(..)->yearly()->timezone(..)
Update 更新资料
The issue is missing /
in usr/bin/php
. 问题是缺少
/
在usr/bin/php
。 /usr/bin/php
fixed the issue /usr/bin/php
解决了该问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.