Cron job Scheduling

Published 6 months ago by ahmedyousuf

hey, I have 500+ scheduling jobs and i want to run it with database i don't want to use crontabs.. how could i manged these job with database??

Nash
Nash
6 months ago (72,030 XP)

Use Laravel's scheduler? It only requires one single cron entry, everything else can be configured through your code.

ahmedyousuf

I have limitation's in my application i can't use cron entry.. can i use it with laravel server?

Nash
Nash
6 months ago (72,030 XP)

What sort of limitations? What is your environment? Where is your app hosted? Are you just serving it locally with artisan serve? Even shared hosting often provides cron jobs through cPanel.

Thyrosis

If you can't use cronjobs, you have to be inventive I guess. And that depends on how scheduled your jobs need to be.

You could route all your requests through a middleware which triggers your jobs. That middleware will store a timestamp in the database and if this call is less then x minutes than the timestamp, it'll just skip and move on. If the timestamp is older than x minutes, the middleware will run or trigger your jobs.

It'll be a real bitch for the visitor who has to wait for the jobs to be run, but hey. You need to think of something. Either that or move to a provider which does allow you to use cronjobs.

Dry7
Dry7
6 months ago (152,030 XP)

@ahmedyousuf create controller or/and route

Route::get('schedule', function() {
    Artisan::call('schedule:run');
});

and add this url in external cron - https://cron-job.org/en/

Please sign in or create an account to participate in this conversation.