2015-09-01 97 views
0

我有一個包含archiver作業的spring項目,我有時想從命令行手動調用它,有沒有一個選項?有沒有辦法從Linux Shell手動調用Spring Quartz Job

<?xml version="1.0" encoding="UTF-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 
xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd 
http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context-2.5.xsd"> 

<bean id="archiverService" class="jobs.service.ArchiverService" /> 

<bean id="myJob" class="jobs.MyJobs" /> 

<bean id="archiverJob" class="org.springframework.scheduling.quartz.JobDetailBean"> 
    <property name="jobClass" value="cmd.jobs.Archiver" /> 
    <property name="jobDataAsMap"> 
     <map> 
      <entry key="myJob" value-ref="myJob" /> 
     </map> 
    </property> 
</bean> 

<bean id="cronTriggerArchiverJob" class="org.springframework.scheduling.quartz.CronTriggerBean"> 
    <property name="jobDetail" ref="archiverJob" /> 
    <property name="cronExpression" value="0 0 23 * * ?" /> 
</bean> 

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean"> 
    <property name="jobDetails"> 
     <list> 
      <ref bean="archiverJob" /> 
     </list> 
    </property> 

    <property name="triggers"> 
     <list> 
      <ref bean="cronTriggerArchiverJob" /> 
     </list> 
    </property> 
</bean> 

</beans> 

回答

2

是的。

Quart Examples Page你會發現Linux.shWindows.bat例子像EXAMPLE1
只需替換您的JDK安裝根目錄即可。

基本上:

$JAVA -classpath $QUARTZ_CP $LOGGING_PROPS org.quartz.examples.example1.SimpleExample 

example1.sh

#!/bin/sh 
# Change this to your JDK installation root 
# 
#JAVA_HOME=/usr/java/jdk1.6.0_18 

JRE=$JAVA_HOME/jre 
JAVA=$JRE/bin/java 

workdir=`dirname $0` 
workdir=`cd ${workdir} && pwd` 
QUARTZ=${workdir}/../.. 

. ${QUARTZ}/examples/bin/buildcp.sh 

if [ `uname | grep CYGWIN` ]; then 
    workdir=`cygpath -w -p $workdir` 
fi 

LOGGING_PROPS="-Dlog4j.configuration=file:${workdir}/log4j.xml" 

$JAVA -classpath $QUARTZ_CP $LOGGING_PROPS org.quartz.examples.example1.SimpleExample 
相關問題