- import java.io.IOException;
- public class Test {
-
- public static void main(String[] args) {
- try {
- Runtime.getRuntime().exec("sh /fxmweb/test/start.sh");
- } catch (IOException e) {
-
- e.printStackTrace();
- }
- }
- }
-
//start.sh
-
-
- find /fxmweb/domains/tstDomain/cgServer -type f ! -ctime -3 -exec rm -f {} \;
以下是xml配置 spring 中设置定时任务
-
-
//Force.java
- import org.quartz.JobExecutionContext;
- import org.quartz.JobExecutionException;
- import org.springframework.scheduling.quartz.QuartzJobBean;
- public class Force extends QuartzJobBean {
- private ForceClearServiceImpl forceClear;
- protected void executeInternal(JobExecutionContext context) throws JobExecutionException
- {
- forceClear.executeComm();
- }
- public ForceClearServiceImpl getForceClear() {
- return forceClear;
- }
- public void setForceClear(ForceClearServiceImpl forceClear) {
- this.forceClear = forceClear;
- }
- }
- //ForceClearServiceImpl .java
- import java.io.IOException;
- import java.util.Iterator;
- import java.util.List;
- public class ForceClearServiceImpl{
-
- private List systemCommands;
- public void executeComm()
- {
- if(systemCommands==null) System.out.println("---------");
- for (Iterator it = systemCommands.iterator(); it.hasNext();) {
- String cmd = (String) it.next();
- System.out.println(cmd);
- try {
- Runtime.getRuntime().exec(cmd);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- public List getSystemCommands() {
- return systemCommands;
- }
- public void setSystemCommands(List systemCommands) {
- this.systemCommands = systemCommands;
- }
- }
发表于 @ 2008年09月19日 10:29:00|评论(loading...)|编辑|收藏