Laravel Cron with Railway
handriki7
FREEOP

4 months ago

I tried to use Laravel Cron and make a schedule for every 2 hour.

Then I put php artisan schedule:run on Railway start up command on a cron service.

Now the thing is the Laravel Cron never run since it looks like the cron service always run the command 1-2 minutes after the "scheduled time", I know a work around to use command directly instead of using laravel cron, but is there any other way?

Since this work around will make new service for every cron. I want to set the cron time on my laravel instead and just put php artisan schedule:run every 5 minute

$10 Bounty

1 Replies

3 months ago

The issue isphp artisan schedule:run only checks once and exits and it doesn't keep running. railway's cron triggers it, but if it fires 1-2 minutes late, Laravel's scheduler thinks the window passed and skips the job.

Use php artisan schedule:work (Service type: Worker (not cron)) instead as your start command. this runs the scheduler continuously in the foreground (checks every minute), so you don't need railway's cron at all. just deploy it as a regular service, not a cron service. Let me know if this helps!


Welcome!

Sign in to your Railway account to join the conversation.

Loading...