You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a scheduled job to generate a number of files and such becasue some can be time expensive. Basically a "create file/report" queue system.
It all works fine and is set to run every minute, every minute the queue of files is processed. however I have been asked if I can remove the waiting period (upto 59 seconds) on the first request without bypassing the lock and AOE's excellent management so that even when triggered straight away it will not ignore the job lock (if it happens to be running already via the generated_schedule it would not run).
This needs to run asyncronously, I realise I can runNow however as I read the code I beleive runNow() would run syncronously so the file creation job would need to complete before code continues from calling runNow().
I thought this must be possible by first scheduling a task for immediate execution (scheduled_at = time()) and then executing the scheduler_cron.sh script via shell_exec.
Enter code example :
//schedule an immediate job$time = time();
$schedule->setJobCode('my_action')
->setScheduledReason("My Actions Immediate Create Dispatch.")
->setStatus(Aoe_Scheduler_Model_Schedule::STATUS_PENDING)
->setCreatedAt(strftime('%Y-%m-%d %H:%M:%S', $time))
->setScheduledAt(strftime('%Y-%m-%d %H:%M:%S', $time))
->save();
//fire the cron manager now just to reduce wait on first reportif ( file_exists(Mage::getBaseDir().DS."scheduler_cron.sh") ){
shell_exec("sh ".Mage::getBaseDir().DS."scheduler_cron.sh > /dev/null 2>/dev/null &");
}
The above code works in that the job is scheduled correctly and the scheduler_cron.sh script does execute (I debugged this with a log file, the sh file is definatelly executing). However the immediately scheduled job does not run! Instead the schedule executes upto a minute later via cron and it marks my immediate job as missed ad executes the generated_schedule one, ergo no instant fire.
Can you advise how I might be able to schedule the action and execute it immediately without bypassing the mutex that AOE Scheduler uses?
Thanks in advance!
Danny Walker
The text was updated successfully, but these errors were encountered:
Blatant
changed the title
Is it possible to schedule a job for immendiate execution and trigger the cron to run asyncronously?
Is it possible to schedule a job for immediate execution and trigger the cron to run asyncronously?
Apr 13, 2018
Here's the situation,
I have a scheduled job to generate a number of files and such becasue some can be time expensive. Basically a "create file/report" queue system.
It all works fine and is set to run every minute, every minute the queue of files is processed. however I have been asked if I can remove the waiting period (upto 59 seconds) on the first request without bypassing the lock and AOE's excellent management so that even when triggered straight away it will not ignore the job lock (if it happens to be running already via the generated_schedule it would not run).
This needs to run asyncronously, I realise I can
runNow
however as I read the code I beleiverunNow()
would run syncronously so the file creation job would need to complete before code continues from callingrunNow()
.I thought this must be possible by first scheduling a task for immediate execution (scheduled_at = time()) and then executing the scheduler_cron.sh script via shell_exec.
Enter code example :
The above code works in that the job is scheduled correctly and the scheduler_cron.sh script does execute (I debugged this with a log file, the sh file is definatelly executing). However the immediately scheduled job does not run! Instead the schedule executes upto a minute later via cron and it marks my immediate job as missed ad executes the generated_schedule one, ergo no instant fire.
Can you advise how I might be able to schedule the action and execute it immediately without bypassing the mutex that AOE Scheduler uses?
Thanks in advance!
Danny Walker
The text was updated successfully, but these errors were encountered: