Reputation:
Hello i'm looking on how to execute a controller function with a cronjob. I've read the documentation but it doesn't explain on how to call a controller function.
I have this function:
function oracle(Request $request)
{
// some get-insert statements using DB Facade
}
Let's say i want to run this function every 10 minutes for each db record that has status = 0
then in laravel scheduler something like:
$schedule->call(function () {
//.. DB query to check all orders that have status = 0
//.. for each record that returns 0
//.. execute oracle()
}
})->everyMinute();
Basically all orders with status 0 are on mysql, now the oracle() logic triggers on a manual click. This function gets data from mysql and inserts to the oracle database. Once the record is on oracle it returns status 1 to mysql. I have to do this with a cron.
Which way should i go for?
Upvotes: -1
Views: 927