Domanda

How can we set timer job so that it will run on specific date of month?
For example, i want schedule timer job to run on 2nd and 28th day of month.
How can we do that?

È stato utile?

Soluzione

I'm not sure if it's possible to configure a timer job in such a way to only fire on given dates, however, you could configure your timer job to run daily but include a date check as the first action in the job.

DateTime date = DateTime.Now;

if (date.Day.Equals(2) || date.Day.Equals(28))
{
    // It's either the 2nd or 28th of the month!
    // Put the rest of the code you want to run in here.
}

else
{
    // Do nothing - it's not the 2nd or 28th.
}

Here is a good walk through if you need more information on creating the timer job, taken from MSDN.

[Edit]

In reference to your comments on this answer. See this article from the sub heading Scheduling a Job to Run Each Day.

Altri suggerimenti

There is no way to schedule timerjob by date. You should create daily timerjob and check if today is the 2nd or 28th day.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a sharepoint.stackexchange
scroll top