SharePoint timer jobs not getting invoked - sharepoint

I have a timer job which has been deployed to a server with multiple Web front ends.
This timer job reads it's configuration from a Hierarchical Object Store.
This timer job is scheduled to run daily on the server.
But the problem is that this timer job is not getting invoked daily. I have implemented event logging in the timer job's Execute() method, but I dont see any logs being generated.
Any ideas as to what could cause a timer job to be not picked up for execution by the SharePoint Timer Service? How can I troubleshoot this problem?
Are there any "gotcha"s for running timer jobs in servers from multiple front ends? Will the timer job get execute in all the web front ends, or any one of them arbitarily? How to know which machine will have my event logs?
This might be a stupid question, but does having multiple front ends for load balancing affect the way Hierarchical Object Stores behave?
EDIT:
One of the commenters, Sean McDounough, (Thanks Sean!! ) made a very good point that:
"whether or not the timer job runs on all WFEs will be a function of the SPJobLockType enum value you specified in the constructor. Using a value of "None" means that the job will run on all WFEs."
Now, my timer job is responsible for sending periodic mails to a list of users. Currently it is marked as SPJobLockType.Job"
If I change this to SPJobLockType.None, does this mean that my timer job will be executed in all the WFEs separately? (THis is not desired, it will spam all the users with multiple emails)
Or does it mean that the timer job will execute in any one of the WFEs, arbitarily?

Try restarting the SharePoint timer service from the command-line using NET STOP SPTIMERV3 followed by a NET START SPTIMERV3. My guess is that the timer service is running with an older version of your .NET assembly. The timer service does not automatically reload assemblies when you upgrade the WSP solution.

To do this, follow these steps:
Stop the Timer service.
Click Start, point to Administrative Tools, and then click Services.
Right-click Windows SharePoint Services Timer, and then click Stop, or Restart service.
This URL helped me.

Related

How to check whether a Timer Job has run

Is it possible to check whether a SharePoint (actually WSS 3.0) timer job has run when it was scheduled to ?
Reason is we have a few daily custom jobs and want to make sure they're always run, even if the server has been down during the time slot for the jobs to run, so I'd like to check them and then run them
And is it possible to add a setting when creating them similar to the one for standard Windows scheduled tasks ... "Run task as soon as possible after a scheduled start is missed" ?
check it in job status page and then you can look at the logs in 12 hive folder for further details
central administration/operations/monitoring/timer jobs/check jobs status
As far as the job restart is concerned when it is missed that would not be possible with OOTB features. and it make sense as well since there are lot of jobs which are executed at particular interval if everything starts at the same time load on server would be very high
You can look at the LastRunTime property of an SPJobDefinition to see when the job was actually executed. As far as I can see in Reflector, the value of this property is loaded from the database and hence it should reflect the time it was actually executed.

JobDefinitions for Timer Jobs in SharePoint

I've hit an issue with creating a timer job on demand from within an event handler. It works fine on my dev machine where the user is also the farm administrator. On the staging server (and production too), this user will be different. Apparently it needs to be a farm admin who creates/updates timer jobs as they have access to the configuration db.
I used a timer job to cope with the notion that many items could be updated at once using the datasheet and if that happened, I wanted an update rollup to take place at a defined period after the edits.
I'm now thinking I may have to set up a recurring timer job instead of a "once" job and within the timer job, check for certain conditions being true before doing any work.
Any suggestions on how I could achieve my desired result of having a rollup function run after any updates, but not after every one?
The previous answer is not correct, or at least not correct for SharePoint 2010. You cannot create job definitions in 2010 in this way even with elevated privileges, as they must be created from central administration. I had a similar problem and this was my finding
this is a blog I wrote about that
I would suggest that you make an event receiver that with a delay of say 10 minutes (timer or thread sleep) and register itself in say web property bag, so that another instance would not run. This could solve the problem.
See http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx to fix the permissions problem.

SharePoint job queued, but never starts

I'm attempting to retract a solution from SharePoint. I've started the job via Central Admin site as well as from stsadm. The job is queued, however, it will stay in a state of pending for days. The SharePoint services - Admin and Timer service - are started.
Any suggestoins of why the retraction jobs are queued, but never started? I'm really at a loss of what to try next, so anything will be helpful.
Thank you!
What happens when you run "STSADM -o execadmsvcjobs" from one of the servers on the farm? this should flush the job queue, displaying any errors occurred along the way.
Make sure the SharePoint 2010 Timer service is running.

Sharepoint Timer Job - Which server does the job execute on?

If I install a (timer job) feature to a Sharepoint front end server within a farm, which server executes the job? All of them?
The job is locked at the job level, and the Execute method calls a web service on one specific machine on the farm, which handles all the processing. My question is whether all the front end servers will try and run this job?
Or network guys want to provide a new server in the farm, so that this job doesn't eat up the resources of the main server, but it sounds to me like we will duplicate the execution of the job.
Confused. Anyone know the answer to this question?
The timer job can actually be deployed to a single instance (or to all of them if you like). This link provides a good answer:
Timer Job deployment via constructors
For SharePoint 2010, see How to: Run Code on All Web Servers:
MyTimerJob myTJ = new MyTimerJob(
"contoso-job-add-mobile-adapter",
webApp,
null,
SPJobLockType.None);
Note the following about this code:
The third parameter can be used to specify a particular server on which the job should run. This is null when the job should run on all front-end Web servers.
The fourth parameter determines whether the job executes on all front-end Web servers. Passing SPJobLockType.None ensures that it runs on all servers on which the Microsoft SharePoint Foundation Web Application service is running. By contrast, passing SPJobLockType.Job ensures that it runs only on the first available server on which the Microsoft SharePoint Foundation Web Application service is running. (There is a third possible value. For more information, see SPJobDefinition and the topics for its constructors and other members.)

How do you instruct a SharePoint Farm to run a Timer Job on a specific server?

We have an SP timer job that was running fine for quite a while. Recently the admins enlisted another server into the farm, and consequently SharePoint decided to start running this timer job on this other server. The problem is the server does not have all the dependencies installed (i.e., Oracle) on it and so the job is failing. I'm just looking for the path of least resistance here. My question is there a way to force a timer job to run on the server you want it to?
[Edit]
If I can do it through code that works for me. I just need to know what the API is to do this if one does exist.
I apologize if I'm pushing for the obvious; I just haven't seen anyone drill down on it yet.
Constraining a custom timer job (that is, your own timer job class that derives from SPJobDefinition) is done by controlling constructor parameters.
Timer jobs typically run on the server where they are submitted (as indicated by vinny) assuming no target server is specified during the creation of the timer job. The two overloaded constructors for the SPJobDefinition type, though, accept an SPServer and an SPJobLockType as the third and fourth parameters, respectively. Using these two parameters properly will allow you to dictate where your job runs.
By specifying your target server as the SPServer and an SPJobLockType of "Job," you can constrain the timer job instance you create to run on the server of your choice.
For documentation on what I've described, see MSDN: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.administration.spjobdefinition.spjobdefinition.aspx.
I don't know anything about the code you're running, but custom timer jobs are commonly setup during Feature activation. I got the sense that your codebase might not be your own (?); if so, you might want to look for the one or more types/classes that derive from SPFeatureReceiver. In the FeatureActivated method of such classes is where you might find the code that actually carries out the timer job instantiation.
Of course, you'll also want to look at the custom timer job class (or classes) themselves to see how they're being instantiated. Sometimes developers will build the instantiation of the class into the class itself (via Factory Method pattern, for example). Between the timer job class and SPFeatureReceiver implementations, though, you should be on the way towards finding what needs to change.
I hope that helps!
Servers in a farm need to be identical.
If you happen to use VMs for your web front ends, you can snap a server and provision copies so that you know they are all identical.
Timer jobs per definition run on all web front ends.
If you need scheduled logic to run on a specific server, you either need to specifically code this in the timer job, or to use a "standard" NT Service instead.
I think a side effect of setting SPJobLockType to 'Job' is that it'll execute on the server where the job is submitted.
You could implement a Web Service with the business logig and deploy that Web Service to one machine. Then your Timer Job could trigger your web service periodically.
The it sould be not that important wher your timer job is running. SharePoint decides itself where to run the timer job.

Resources