Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: Liferay Scheduler
Hi all.
I am developing my first scheduler and I have some doubts regarding how to specify when it has to be executed. I want it to be launched once a day, at the same hour.
If I understood it correctly, I have to set activate method for it. I am able to specify that it is launched once a day, but I don't know how to specified the hour.
I saw that setTrigger method has these definitions, but I don't know that is the "cronExpression" parameter.
Any help would be appreciated.
Thanks in advance,
Kind regards
I am developing my first scheduler and I have some doubts regarding how to specify when it has to be executed. I want it to be launched once a day, at the same hour.
If I understood it correctly, I have to set activate method for it. I am able to specify that it is launched once a day, but I don't know how to specified the hour.
schedulerEntryImpl.setTrigger (
TriggerFactoryUtil.createTrigger(getEventListenerClass(), getEventListenerClass(), 24, TimeUnit.HOUR));
I saw that setTrigger method has these definitions, but I don't know that is the "cronExpression" parameter.
- createTrigger(String jobName, String groupName, Date startDate, Date endDate, int interval, TimeUnit timeUnit)
- createTrigger(String jobName, String groupName, Date startDate, Date endDate, String cronExpression)
- createTrigger(String jobName, String groupName, Date startDate, int interval, TimeUnit timeUnit)
- createTrigger(String jobName, String groupName, Date startDate, String cronExpression)
- createTrigger(String jobName, String groupName, int interval, TimeUnit timeUnit)
- createTrigger(String jobName, String groupName, String cronExpression)
Any help would be appreciated.
Thanks in advance,
Kind regards
Hi Daniel,
CronExpression is a string that defines when your task is run. It follows more or less the format of unix crontab and you can build with something it like this:
You can use "*" instead of a number so a string like "0 0 0 * * * *" will run every day at midnight.
HTH
Fernando
CronExpression is a string that defines when your task is run. It follows more or less the format of unix crontab and you can build with something it like this:
String.format("%s %s %s %s %s ? %s", secs, mins, hrs, dom, mon, year)
You can use "*" instead of a number so a string like "0 0 0 * * * *" will run every day at midnight.
HTH
Fernando
There are also some online cron builders available e.g.
http://www.cronmaker.com/
(First search hit for me, didn't really test it beyond a quick try)
http://www.cronmaker.com/
(First search hit for me, didn't really test it beyond a quick try)
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™