Forums

Home » Liferay Portal » English » 2. Using Liferay » General

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Pepe Perez
Create a new scheduler in a Liferay hook
February 11, 2013 10:56 AM
Answer

Pepe Perez

Rank: New Member

Posts: 14

Join Date: September 18, 2012

Recent Posts

Hi,

I need to create a new scheduler in Liferay 6.1.1 to execute a process every night at 3:00 AM, but I would like to do it in a new hook, not in a portlet. Please, is there any easy way to do this?

Thanks.

Regards.
David H Nebinger
RE: Create a new scheduler in a Liferay hook
February 11, 2013 1:21 PM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11788

Join Date: September 1, 2006

Recent Posts

Not in a hook, no. You could do it via an EXT, but not a hook.
Hitoshi Ozawa
RE: Create a new scheduler in a Liferay hook
February 11, 2013 2:00 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Is there a reason that you don't want to create a portlet instead of a hook? You're essentially adding a new functionality. It's possible to hard code the 3:00 AM but it's really better to create a configuration page where admin can set the time.
Pepe Perez
RE: Create a new scheduler in a Liferay hook
February 12, 2013 12:33 AM
Answer

Pepe Perez

Rank: New Member

Posts: 14

Join Date: September 18, 2012

Recent Posts

Ok, if I do it with a portlet, is there any way to start the scheduler when Liferay is deployed?

Sorry if my question is kind of weird. I'm a beginner in this.

Thanks.

Regards.
Hitoshi Ozawa
RE: Create a new scheduler in a Liferay hook
February 12, 2013 12:59 AM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Ok, if I do it with a portlet, is there any way to start the scheduler when Liferay is deployed?


What do you mean "Liferay is deployed"? Are you deploying liferay war file? Can just deploy the portlet war after deploying liferay war file.

If you mean when liferay is started, don't see any problem with using portlet.
Vilmos Papp
RE: Create a new scheduler in a Liferay hook
February 12, 2013 1:58 AM
Answer

Vilmos Papp

LIFERAY STAFF

Rank: Liferay Master

Posts: 521

Join Date: October 21, 2010

Recent Posts

Hi,

Please check http://www.liferay.com/dtd/liferay-portlet-app_6_2_0.dtd and examine scheduler-entry element. If you specify it you can set your own scheduler for your portlet with the scheduling as well:

 1
 2<scheduler-entry>
 3    <scheduler-event-listener-class>com.mycompany.portlet.test.TestPortlet</scheduler-event-listener-class>
 4    <trigger>
 5        <cron>
 6            <cron-trigger-value>0 0/1 * 1/1 * ? *</cron-trigger-value>
 7        </cron>
 8    </trigger>
 9</scheduler-entry>


Regards,
Vilmos
Pepe Perez
RE: Create a new scheduler in a Liferay hook
February 12, 2013 8:30 AM
Answer

Pepe Perez

Rank: New Member

Posts: 14

Join Date: September 18, 2012

Recent Posts

Done :-)

Thank you all.

Regards.