Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to create cron job in liferay

    • 0
    • 1
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 2.33k
    Comment on it

    Cron job is a UNIX tool, its scheduling capabilities are powerful and proven. The CronTrigger class of cron is based on the scheduling capabilities.


    CronTrigger uses “cron expressions”, which are able to create firing schedules such as: “At 8:00am every Monday through Friday”


    Follow the below steps to create cron job in liferay :

    Step 1: Create a Scheduler class and put below code :

    package com.bhagwan;
    import com.liferay.portal.kernel.messaging.Message;
    import com.liferay.portal.kernel.messaging.MessageListener;
    import com.liferay.portal.kernel.messaging.MessageListenerException;
    public class CronJobListener implements MessageListener {
       public void receive(Message message) throws MessageListenerException {
          //Here is the buisness logic to be written as per your requirement


    Step 2: Specify the scheduler class in the liferay-portlet.xml

          This scheduler is used to run my own job
          <!-- <property-key></property-key> -->
             <cron-trigger-value>0 0 0 * * ?</cron-trigger-value>


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: