Frage

What i should do to run CRON trigger to run now once and follow the expression for Example

trigger that simply fires every 5 minutes.

I have gone through the below post

https://groups.google.com/forum/#!topic/quartznet/GAv10E4TJ50

If you want to make sure your job is run immediately you can set start time to one day before DateTime.Now, so you change your code to:

CronTrigger trigger = new CronTrigger("trig", "grp", "job", "grp", DateTime.Now.AddDays(-1), null, "0 0 0 * * ?");

But does the above work for any scenario. like 0 0/5 14 * * ? Fire every 5 minutes starting at 2pm and ending at 2:55pm, every day (if current time is 2:15pm)

Thanks, Kusuma

War es hilfreich?

Lösung 2

The time at which the trigger's scheduling should start. May or may not be the first actual fire time of the trigger, depending upon the type of trigger and the settings of the other properties of the trigger. However the first actual first time will not be before this date. So i could able to run immediately by setStartTime

Andere Tipps

What about creating a CRON trigger with a temporary schedule to "trigger the job now" (e.g. 0 * * * * ?) and implementing a JobListener that would update the CRON trigger's expression once the job has been executed for the first time? You can use, for example, a job data map parameter to distinguish the first and subsequent executions in the listener.

If you do not insist that it must always be the same CRON trigger that "executes the job now" and then continues to execute it regularly, then you can use one of the triggerJob methods that both create a temporary on-off SimpleTrigger that is used to execute the job now.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top