I have created a Web application scoped timer job in SharePoint 2013. This timer job is supposed to be running only once in a month , and should send an email only once . The problem i am facing is this job is running multiple times ,we have 2 WFE servers and it is running from both one by one. I checked several blogs and everyone says to put
(SPJobLockType.job)
in the constructor :
public TimerJob(string jobName, SPWebApplication webapp)
: base(jobName, webapp, null, SPJobLockType.Job)
{
this.Title = "My Timer Job";
}
which i have already done . the code is as below:
class TimerJob : SPJobDefinition
{
public TimerJob()
: base()
{
}
public TimerJob(string jobName, SPService service)
: base(jobName, service, null, SPJobLockType.Job)
{
this.Title = "My Timer Job";
}
public TimerJob(string jobName, SPWebApplication webapp)
: base(jobName, webapp, null, SPJobLockType.Job)
{
this.Title = "My Timer Job";
}
public override void Execute(Guid targetInstanceId)
{
UpcomingNotifications.Run();
}
}
Please suggest me something guys that this timer job should not run more than once.