I think we can stop cronjob by hmc. If except that any ways are there please answer
4 Answers
You can find an answer in the more global problematic of how to stop an infinite loop in a thread. (See : https://stackoverflow.com/a/2358169/1140748)
Your job is launched in a dedicated Thread.
The only way you have to stop it is to use a flag that can be set from an outside object.
In your JobPerformable
(that extends AbstractJobPerformable
) you have to often set this block of code to check if the cron should be stopped :
if (clearAbortRequestedIfNeeded(cronJobModel)) {
LOG.error(String.format(MSG_INFO_JOB_ABORTED, cronJobModel.getCode()));
return new PerformResult(CronJobResult.UNKNOWN, CronJobStatus.ABORTED);
}
The JobPerformable
must be "abortable". To say that put this bloc of code in the JobPerformable implementation :
@Override
public boolean isAbortable()
{
return true;
}

- 1
- 1

- 19,951
- 10
- 65
- 112
You can always abort your Cronjob from HMC using (Abort Cronjob button), however your job should be an abortable job, if it's not you will not be able to stop it.
Check this tutorial on How to Write an Abortable Job.

- 3,609
- 2
- 23
- 37
-
Actually I want to know that except HMC ,any other ways are there through which we can stop cronjob? – Lcoder_001 Feb 09 '17 at 09:17
-
Another solution is to try and update(with Finished state) or delete your cronjob via impex file. – Hristo Staykov Feb 09 '17 at 09:51
-
I do not think that if you change the status of the cron job to Finished or Aborted will stop it. – Mouad EL Fakir Feb 09 '17 at 11:33
-
Can you please tell the proper way then ? – Lcoder_001 Feb 09 '17 at 12:59
-
The proper way is the one described in the answer above, i don't think that there is another way to do it. – Mouad EL Fakir Feb 09 '17 at 14:08
Actually there are several ways to stop cronjob in Hybris.
First and best approach is to abort it from HMC
(now Backoffice Administration Cockpit
). For that to be possible cronjob has to be abortable
. More on abortable cronjobs here.
You can also abort cronjobs from HAC
by going to Monitoring
> Cron Jobs
. This works more or less the same way it does in the first approach.
There are also some ways to abort/stop/finish cronjob when the first two are not available:
- You can remove cronjob by impex import or directly on the database.
- You can set cronjob's status to
FINISHED
by impex import or on database. - You can do both (1. and 2.) also by
webservice API
I believe. More on webservice API here.
Last but not least, you can abort the cronjob programmatically using:
cronJobService.requestAbortCronJob(myCronJobModel);
In this case cronjob has to be abortable
as well.
More on cronjobs here.

- 295
- 5
- 17
-
I think if the cronjob is not abortable none of those points will make it stop, (removing the cronjob is not appropriate in my opinion, i prefer restart the server rather than removing the cronJob, because the cronJob may hold some historical/interesting information, and i don't want them to be erased). – Mouad EL Fakir Feb 09 '17 at 16:51
-
But I want know without interrupting server how can we stop cronjob ? – Lcoder_001 Feb 11 '17 at 10:55
run below impex in hac
update CronJob[batchmode=true];itemtype(code)[unique=true];active;CronJob;false

- 1,050
- 10
- 17