Fórum
cron text format for scheduled job - chosen week days
Andrzej Drozdowski, modificado 11 Anos atrás.
cron text format for scheduled job - chosen week days
Junior Member Postagens: 27 Data de Entrada: 03/09/10 Postagens Recentes
Hi
I would like to schedule a job programitically. I want it runs few times a week for example at 5AM on Mondays and Wednesdays.
I have tried to use cron text: 0 0 5 * * 1,3 * but it does not work. The job seems to run every minute.
Then I tried 0 10 5 * * ? * and the job is scheduled properly - every day.
Does anybody knows the right format to choose week days?
My code:
Liferay 6.1
Thank You
A.D.
I would like to schedule a job programitically. I want it runs few times a week for example at 5AM on Mondays and Wednesdays.
I have tried to use cron text: 0 0 5 * * 1,3 * but it does not work. The job seems to run every minute.
Then I tried 0 10 5 * * ? * and the job is scheduled properly - every day.
Does anybody knows the right format to choose week days?
My code:
MessageBusUtil.registerMessageListener(
DestinationNames.SCHEDULER_DISPATCH, new ImportJob());
String cronText = "0 " + minuteCron + " " + hourCron + " * * "
+ weekdaysCron + " *";
Trigger trigger = new CronTrigger("Import Job", "Import", new Date(),
null, cronText);
Message message = new Message();
try {
SchedulerEngineUtil.schedule(trigger, StorageType.PERSISTED,
"Import Job", DestinationNames.SCHEDULER_DISPATCH, message,
10);
} catch (SchedulerException e) {
log.error("cannot schedule the job", e);
}
Liferay 6.1
Thank You
A.D.
David H Nebinger, modificado 11 Anos atrás.
RE: cron text format for scheduled job - chosen week days
Liferay Legend Postagens: 14915 Data de Entrada: 02/09/06 Postagens Recentes
Usually you should include a 'no specific value' reference (the ? character) in your expression.
Try "0 0 5 ? * 1,3 *".
Try "0 0 5 ? * 1,3 *".
Andrzej Drozdowski, modificado 11 Anos atrás.
RE: cron text format for scheduled job - chosen week days
Junior Member Postagens: 27 Data de Entrada: 03/09/10 Postagens Recentes
Thank You!
I used your cron text. The job is scheduled as defined (next monday), and the information is saved properly in database but it also runs every minute.
What could be the reason?
And another question.
I would like to delete the job. My cod is:
The schedule is not deleted - is still in database table.
How should I delete the schedule?
Regards,
A.D.
I used your cron text. The job is scheduled as defined (next monday), and the information is saved properly in database but it also runs every minute.
What could be the reason?
And another question.
I would like to delete the job. My cod is:
SchedulerEngineUtil.delete("Import Job", "Import",
StorageType.PERSISTED);
The schedule is not deleted - is still in database table.
How should I delete the schedule?
Regards,
A.D.
David H Nebinger, modificado 11 Anos atrás.
RE: cron text format for scheduled job - chosen week days
Liferay Legend Postagens: 14915 Data de Entrada: 02/09/06 Postagens Recentes
The cron schedule is right, but if it is also going every minute I'm wondering if perhaps you have an older scheduled task defined for that (either in the database or liferay-portlet.xml or what not).
Andrzej Drozdowski, modificado 11 Anos atrás.
RE: cron text format for scheduled job - chosen week days
Junior Member Postagens: 27 Data de Entrada: 03/09/10 Postagens Recentes
Hi,
Despite many attempts I cannot make it to work.
I have tried also with:
It looks like quartz is not triggering the job.
I have looked into quartz tables - job and cron records are OK.
SchedulerEngineUtil.getNextFireTime() shows proper time.
When time is up nothing happens.
Please hint me, what could be the reason.
Any help will be appreciated.
Regards
A.D
Despite many attempts I cannot make it to work.
I have tried also with:
SchedulerEntry schedulerEntry = new SchedulerEntryImpl();
schedulerEntry.setEventListenerClass(ImportJob.class.getName());
schedulerEntry.setTriggerValue(cronText);
schedulerEntry.setTriggerType(TriggerType.CRON);
schedulerEntry.setDescription("job description");
try {
SchedulerEngineUtil.schedule(new ImporterSchedulesEntry(cronText),
StorageType.PERSISTED, null, 0);
It looks like quartz is not triggering the job.
I have looked into quartz tables - job and cron records are OK.
SchedulerEngineUtil.getNextFireTime() shows proper time.
When time is up nothing happens.
Please hint me, what could be the reason.
Any help will be appreciated.
Regards
A.D