1

I am creating an app using magento 2 where user is supposed to upload csv file containing:

  1. Name of base image
  2. Name of clipart
  3. height
  4. Width
  5. top margin
  6. left margin

using above data I am suppose to combine both the images.

I am using cronjob to finish up this task, like as soon as user clicks on generate images first I am inserting all data into database and then using cron job, combining all the images after each minute.

The problem is cron job is still inserting data even after it has finished combining images. I want to stop cron job as soon as it finishes the task.

can I run cron job based on some condition or something?

1 Answers1

0

The cron job always run by a schedule, so you have to add your condition within your code. Something like this:

if($this->isCombined()){
   return false;
}

Cheers

bachlee89
  • 717
  • 4
  • 8
  • can u please explain it in details? like will this block stop cron from executing? my question is cron should not run in background once task is finished i.e. it should not create any entries in database after that. – Dipak Sumesara Dec 07 '18 at 03:57