Dushyanth Kandiah
Dushyanth Kandiah

Reputation: 716

How to run hangfire on a specific day in a week

I want to run a schedule on thursday 12:00 a.m. every week how to write the cron?

Upvotes: 1

Views: 1237

Answers (2)

JJ173
JJ173

Reputation: 281

In this case, you would want the Cron.Weekly(DayOfWeek, Hour).

The IRecurringJobManager interface has a method for adding or updating your tasks (AddOrUpdate). That method contains an argument for specifying a timeframe.

If you're using a startup project, you would add your task like so:

fooJobManager.AddOrUpdate("TaskName", exampleFunctionToRun, Cron.Weekly(DayOfWeek.Thursday, 0));

Upvotes: 3

StPaulis
StPaulis

Reputation: 2916

I believe that this is the expression that you want: 0 12 */7 * 4

It is representing `min hour day month day-of-week'.

Upvotes: 0

Related Questions