My aim is to schedule and run a task every day at midnight. I already use Beanstalkd in my application for other scheduling purposes. But running a job every day at a specific time seems to be a bit difficult.
I schedule the job to run at 00:00 every day in my global.php
file:
Queue::later($secondsBeforeMidNight, $jobToFire, array('data' => $data));
However, the thing about Laravel is that it boots up the entire application every time a request is received. Meaning, the above task would be scheduled every time a new request comes in. This will result in creating a myriad of jobs waiting to be fired at midnight.
Is there any way to solve this issue?
You should be using cron
for this - not Beanstalkd.
For Laravel 4 the best option is to use the Dispatcher package: https://github.com/Indatus/dispatcher
This will allow you to schedule specific artisan commands to run at various times.