Schedule task to run everyday at specific time with Quartz.NET
up vote
3
down vote
favorite
I am using Quartz.NET for doing a task everyday at specific hour and this is my code:
public class TestSchedule : ISchedule
{
public void Run()
{
DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
.Build();
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sc = sf.GetScheduler();
sc.ScheduleJob(job, trigger);
sc.Start();
}
}
my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0)
)
now, how can say that run everyday at 7 o'clock?
PS : I don't want use CronTrigger
to do that.
quartz-scheduler quartz.net
add a comment |
up vote
3
down vote
favorite
I am using Quartz.NET for doing a task everyday at specific hour and this is my code:
public class TestSchedule : ISchedule
{
public void Run()
{
DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
.Build();
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sc = sf.GetScheduler();
sc.ScheduleJob(job, trigger);
sc.Start();
}
}
my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0)
)
now, how can say that run everyday at 7 o'clock?
PS : I don't want use CronTrigger
to do that.
quartz-scheduler quartz.net
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I am using Quartz.NET for doing a task everyday at specific hour and this is my code:
public class TestSchedule : ISchedule
{
public void Run()
{
DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
.Build();
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sc = sf.GetScheduler();
sc.ScheduleJob(job, trigger);
sc.Start();
}
}
my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0)
)
now, how can say that run everyday at 7 o'clock?
PS : I don't want use CronTrigger
to do that.
quartz-scheduler quartz.net
I am using Quartz.NET for doing a task everyday at specific hour and this is my code:
public class TestSchedule : ISchedule
{
public void Run()
{
DateTimeOffset startTime = DateBuilder.FutureDate(2, IntervalUnit.Second);
IJobDetail job = JobBuilder.Create<HelloJob>()
.WithIdentity("job1")
.Build();
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithDailyTimeIntervalSchedule(x => x.OnEveryDay().StartingDailyAt(new TimeOfDay(7, 0)).WithRepeatCount(0))
.Build();
ISchedulerFactory sf = new StdSchedulerFactory();
IScheduler sc = sf.GetScheduler();
sc.ScheduleJob(job, trigger);
sc.Start();
}
}
my code is working, but problem is that works only once(it seems that , it's because WithRepeatCount(0)
)
now, how can say that run everyday at 7 o'clock?
PS : I don't want use CronTrigger
to do that.
quartz-scheduler quartz.net
quartz-scheduler quartz.net
edited Nov 11 at 6:47
Cœur
17k9102140
17k9102140
asked Jun 25 '13 at 5:11
Sirwan Afifi
7,60874082
7,60874082
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
DailyTimeIntervalTriggerImpl only support repeatCount.
This trigger also supports "repeatCount" feature to end the trigger
fire time after a certain number of count is reached. Just as the
SimpleTrigger, setting repeatCount=0 means trigger will fire once
only! Setting any positive count then the trigger will repeat count +
1 times. Unlike SimpleTrigger, the default value of repeatCount of
this trigger is set to REPEAT_INDEFINITELY instead of 0 though.
Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.
Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
.Build();
1
Another solution would be.EndingDailyAfterCount(1)
instead of.WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.
– Christian
Mar 27 '17 at 7:40
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
DailyTimeIntervalTriggerImpl only support repeatCount.
This trigger also supports "repeatCount" feature to end the trigger
fire time after a certain number of count is reached. Just as the
SimpleTrigger, setting repeatCount=0 means trigger will fire once
only! Setting any positive count then the trigger will repeat count +
1 times. Unlike SimpleTrigger, the default value of repeatCount of
this trigger is set to REPEAT_INDEFINITELY instead of 0 though.
Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.
Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
.Build();
1
Another solution would be.EndingDailyAfterCount(1)
instead of.WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.
– Christian
Mar 27 '17 at 7:40
add a comment |
up vote
4
down vote
accepted
DailyTimeIntervalTriggerImpl only support repeatCount.
This trigger also supports "repeatCount" feature to end the trigger
fire time after a certain number of count is reached. Just as the
SimpleTrigger, setting repeatCount=0 means trigger will fire once
only! Setting any positive count then the trigger will repeat count +
1 times. Unlike SimpleTrigger, the default value of repeatCount of
this trigger is set to REPEAT_INDEFINITELY instead of 0 though.
Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.
Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
.Build();
1
Another solution would be.EndingDailyAfterCount(1)
instead of.WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.
– Christian
Mar 27 '17 at 7:40
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
DailyTimeIntervalTriggerImpl only support repeatCount.
This trigger also supports "repeatCount" feature to end the trigger
fire time after a certain number of count is reached. Just as the
SimpleTrigger, setting repeatCount=0 means trigger will fire once
only! Setting any positive count then the trigger will repeat count +
1 times. Unlike SimpleTrigger, the default value of repeatCount of
this trigger is set to REPEAT_INDEFINITELY instead of 0 though.
Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.
Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
.Build();
DailyTimeIntervalTriggerImpl only support repeatCount.
This trigger also supports "repeatCount" feature to end the trigger
fire time after a certain number of count is reached. Just as the
SimpleTrigger, setting repeatCount=0 means trigger will fire once
only! Setting any positive count then the trigger will repeat count +
1 times. Unlike SimpleTrigger, the default value of repeatCount of
this trigger is set to REPEAT_INDEFINITELY instead of 0 though.
Cron expressions are beautiful and there's loads of tools which can help you to achieve what you're looking for.
Another alternative would be to use a SimpleTriggerImpl and set the interval every 24 hours:
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity("trigger1")
.StartAt(startTime)
.WithSimpleSchedule(x => x.RepeatForever().WithIntervalInHours(24))
.Build();
answered Jun 25 '13 at 11:09
LeftyX
27.7k17110173
27.7k17110173
1
Another solution would be.EndingDailyAfterCount(1)
instead of.WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.
– Christian
Mar 27 '17 at 7:40
add a comment |
1
Another solution would be.EndingDailyAfterCount(1)
instead of.WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.
– Christian
Mar 27 '17 at 7:40
1
1
Another solution would be
.EndingDailyAfterCount(1)
instead of .WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.– Christian
Mar 27 '17 at 7:40
Another solution would be
.EndingDailyAfterCount(1)
instead of .WithIntervalInHours(24)
. So you won't get into troubles with DST (daylight saving time) related issues.– Christian
Mar 27 '17 at 7:40
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f17289568%2fschedule-task-to-run-everyday-at-specific-time-with-quartz-net%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown