Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

LYiub's avatar
Level 1

Laravel CRON is working only by command manually, and not trigger the command everyMinute

I already have laravel 5.4 app in AWS Ubuntu, in my project I have a command to send email everyMinute for a user.

It is working fine if I run the command php artisan activity:update , and if I run php artisan schedule:run , it is also working well and the user received that email just once.

However, I still don't know why the everyMinute function in command not working and I can't receive the email everyMinute. My Kernal:

protected $commands = [
    Commands\Inspire::class,
    Commands\ActivityDateChecker::class,
    Commands\Test::class
];


protected function schedule(Schedule $schedule)
{
    $schedule->command('activity:update')
             ->everyMinute();
}

I already read some articles mentioned that need to add the schedule command (* * * * * /usr/bin/php /var/www/html/Projectname/artisan schedule:run >> /dev/null 2>&1) running in crontab,

When I run crontab -e I got:

no crontab for ec2-user - using an empty one
~
~
~
~
~
~
~
~
~
"/tmp/crontab.p7jciw" 0L, 0C

So I found another way to open crontab, by using: sudo vi /etc/crontab I got this screen:

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/

# For details see man 4 crontabs

# Example of job definition:
# .---------------- minute (0 - 59)
# |  .------------- hour (0 - 23)
# |  |  .---------- day of month (1 - 31)
# |  |  |  .------- month (1 - 12) OR jan,feb,mar,apr ...
# |  |  |  |  .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
# |  |  |  |  |
# *  *  *  *  * user-name command to be executed

~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               

and when I put this line (* * * * * /usr/bin/php /var/www/html/Projectname/artisan schedule:run >> /dev/null 2>&1) (copy/paste) and I tried to save it, I couldn't save it because of the permission of username

First, Do I need to embed it in crontab to make the command working everyMinute? and where is the missing part in my code that make it not trigger auto everyMinute?

Second: How I can make my command running everyMinute, while it is working manually, just the automated part not working.

0 likes
1 reply
Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

You need to open the crontab for the user that handles your website

sudo crontab -e -u ec2-user
1 like

Please or to participate in this conversation.