Execute a recurring job in Hangfire every 8 days

后端 未结 2 1748
执念已碎
执念已碎 2021-02-07 11:16

Is it possible to create a recurring job in Hangfire that executes after a given number of days, say 8.

The nearest I found was to execute a job once in a week -

<
2条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-07 11:44

    Finally I have used CronExpression like this to schedule a recurring job with frequency of every 8 days or for any number of days for that matter.

    string cronExp = "* * */8 * *";
    RecurringJob.AddOrUpdate("MyJob",() => ScheduledJob(), cronExp);
    

    The third segment in CronExpression represents day of month.

    The respective segments are as follows - (Ref: https://en.wikipedia.org/wiki/Cron)

提交回复
热议问题