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>
By doesn't work I guess you mean the trigger never fires. Maybe because it has no delay it misfires? What about adding <start-time-seconds-in-future/>
with some time in the 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>
If it works for you, you must be aware of something which you might consider either a bug or a feature: if you restart the server, because the trigger already fired and was removed, it will fire again. See: Quartz XML plugin reschedules fired triggers after restart.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With