SharePoint Timer Job is running but not executing

2.3k Views Asked by At

This feature is scoped at the site collection level. When the feature activated, the timer job is created in the web application with a generic name that includes the site collection URL that it's supposed to run in. In theory, when deactivating the feature in a site collection, it stops executing there, but any other timer job feature activated on a different site collection would still run.

using Microsoft.SharePoint
using Microsoft.SharePoint.Administration

class DailyAlerts() : SPJobDefinition
{
   public DailyAlerts() : base() { }

   public DailyAlerts(string jobName, SPWebApplication webApp) : base(jobName, webApp, null, SPJobLockType.Job)
   {
      this.Title = jobName;
   }

   public override void Execute(Guid targetInstanceId)
   {
      // CHANGE THE SITE COLLECTION'S ROOT WEB SITE DESCRIPTION TO THE CURRENT TIME
   }
}

After deploying the solution, and activating it on one site collection, the job never executed any custom code. This article helped remedy that: http://www.wahidsaleemi.com/2009/08/sharepoint-timer-jobs-not-running/. After stopping the SP timer server, deleting the cached XML files, and started the service, the activated site collection timer job executed perfectly.

However activating the custom timer feature on a different site collection, caused the same initial problem of that particular site collection's timer job not executing. The first timer job (post clear cache) still works fine.

Since certain users have control can turn on/off features, you can see how this can get frustrating for people. When new site collections are made, the feature will have to be activated, but it will not run until...the cache is cleared? What am I missing here?

Thanks in advance.

1

There are 1 best solutions below

2
On BEST ANSWER

The service can be reset with powershell, What i would suggest is to put a description on the feature just to say that the features full functionality will not become apparent until the following day.

Get your feature to update a property bag variable at say farm or web app level.

Write a powershell script to then scan for the variable, A run the script if the variable equals true and notify someone of the restart. Obviously reset the variable back to what it was originally. Tie this script to the task scheduler of one of the SP servers to run once in the night away from any backups and search jobs. This means should you need to kick it off manually you can do so via the task scheduler also!

This will then mean the process is automated but your only forcing the timer job to restart when required.

Cheers Truez