论坛

主页 » Liferay Portal » English » 3. Development

组合视图 统一视图 树状图
讨论主题 [ 上一个 | 下一个 ]
toggle
Shashant Panwar
Cron scheduler not executing .sh command
2013年1月11日 下午1:52
答复

Shashant Panwar

等级: Junior Member

帖子: 28

加入日期: 2012年9月21日

最近的帖子

Hi ,
I have created a liferay cron scheduler and it is working fine.But when I add a '.sh' command to execute along with it then in that case only "receive" method(Scheduler class method) is executing, my script is not executing.Can someone help me with this?
Am I doing something wrong or liferay does not support '.sh' or '.pl' execution in <cron-trigger-value> ?
Here is my code and liferay-portlet.xml entry:

Java Code:

import com.liferay.portal.kernel.messaging.Message;
import com.liferay.portal.kernel.messaging.MessageListener;
import com.liferay.portal.kernel.messaging.MessageListenerException;

public class Schedular implements MessageListener {

int i = 1;
public void receive(Message arg0) throws MessageListenerException {

//Here is the buisness logic to be written as per your requirement
System.out.println("Scheduler has been started; "+ "value is: "+ i);
i++;
}

}

Liferay-portlet.xml entry:
<scheduler-entry>
<scheduler-event-listener-class>com.ys.schedule.Schedular</scheduler-event-listener-class>
<trigger>
<cron>
<cron-trigger-value>0 0/1 * 1/1 * ? * /Users/shashantp/Projects/testFolder/text1.sh</cron-trigger-value>
</cron>
</trigger>
</scheduler-entry>

Thanks & Regards,
Shashant
Jelmer Kuperus
RE: Cron scheduler not executing .sh command
2013年1月13日 上午1:38
答复

Jelmer Kuperus

等级: Liferay Legend

帖子: 1192

加入日期: 2010年3月10日

最近的帖子

You should not add a reference to the script to the cron-trigger-value

You should execute that script from within the receive method of your "Schedular" (sic) using ProcessBuilder or commons-exec
Shashant Panwar
RE: Cron scheduler not executing .sh command
2013年1月14日 下午9:08
答复

Shashant Panwar

等级: Junior Member

帖子: 28

加入日期: 2012年9月21日

最近的帖子

Thanks Jelmer.
Also, Is there any way I can dynamically pass cron values to cron-trigger-value tag or stop it dynamically.
My scenario is: I will receive a file at a location, my job will keep on polling on that directory .the moment job will get the file it wil process it.
Now I want to stop the job the moment my job finds the file and process it,so that it will not process the file recursively as I have a limitation neither I can remove the file nor change the name.
I have to run the job on 24th of every month.

Thanks,
Shashant