If cron_job() is my function running the cron job
function cron_job(){
// I would like to get the current job_id or the cron schedule model here
}
Is there any way to retrieve this data in Magento version > 1.9
If cron_job() is my function running the cron job
function cron_job(){
// I would like to get the current job_id or the cron schedule model here
}
Is there any way to retrieve this data in Magento version > 1.9
The cronjob methods can take a Mage_Cron_Model_Schedule parameter which contains the job metadata (you can even change it).
function cron_job(Mage_Cron_Model_Schedule $schedule)
{
$id = $schedule->getId(); // ID in `cron_schedule` database table
$jobCode = $schedule->getJobCode();
$status = $schedule->getStatus(); // will be "running" obviously
$messages = $schedule->getMessages();
$createdAt = $schedule->getCreatedAt();
$scheduledAt = $schedule->getScheduledAt();
$executedAt = $schedule->getExecutedAt();
$finishedAt = $schedule->getFinishedAt(); // will be empty since the job is not finished yet
}