簡體   English   中英

有沒有一種方法可以從Linux Shell手動調用Spring Quartz Job

[英]Is there a way to invoke manually Spring Quartz Job from Linux Shell

我有一個帶有存檔程序工作的spring項目,有時我想從命令行手動調用它,是否有選項?

<?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>

是。

Quart示例頁面中,您將找到Linux.sh Windows.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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM