5

I'm trying to set up a job such that it runs once the first time my scheduler is started, then once at midnight every day after that. Here is my XML for the job and triggers. The once a day trigger works, but the one-time trigger does not.

    <job>
      <name>MyJob</name>
      <group>MyJobGroup</group>
      <job-type>MyScheduledJob, MyJobAssembly</job-type>
      <description>My job, yo</description>
      <durable>true</durable>
      <recover>false</recover>
    </job>
    <trigger>
      <cron>
        <name>MyTrigger</name>
        <group>MyTriggerGroup</group>
        <job-name>MyJob</job-name>
        <job-group>MyJobGroup</job-group>
        <cron-expression>0 0 0 1/1 * ? *</cron-expression>
      </cron>
        <simple>
            <name>MyOneTimeTrigger</name>
            <group>MyTriggerGroup</group>
            <description>Run once at startup, G</description>
            <misfire-instruction>SmartPolicy</misfire-instruction>
            <volatile>false</volatile>
            <job-name>MyJob</job-name>
            <job-group>MyJobGroup</job-group>
            <repeat-count>0</repeat-count>
            <repeat-interval>0</repeat-interval> 
      </simple>
    </trigger>
4

1 回答 1

4

不起作用猜你的意思是触发器永远不会触发。也许是因为它没有延迟它会失火?<start-time-seconds-in-future/>以后有时间再添加怎么样?

<simple>
        <name>MyOneTimeTrigger</name>
        <group>MyTriggerGroup</group>
        <description>Run once at startup, G</description>
        <misfire-instruction>SmartPolicy</misfire-instruction>
        <volatile>false</volatile>
        <job-name>MyJob</job-name>
        <job-group>MyJobGroup</job-group>
        <start-time-seconds-in-future>60</start-time-seconds-in-future>
        <repeat-count>0</repeat-count>
        <repeat-interval>0</repeat-interval> 
</simple>

如果它对您有用,您必须注意一些您可能认为是错误或功能的东西:如果您重新启动服务器,因为触发器已经触发并被删除,它将再次触发。请参阅:Quartz XML 插件重新安排重新启动后触发的触发器

于 2012-05-21T16:29:24.433 回答