SharePoint custom timer job execution issue

2.1k views Asked by At

We have developed a timer job for SharePoint 2013 in Visual Studio 2012. It is scheduled to be running between 7 AM to 7:15 AM. We have deployed the timer job using PowerShell. In code we have added PortalLog.LogString to log messages in SharePoint error logs at the beginning of the timers execute method.

Under Site Collection we can see that it is deployed and activated. The scope of the timer job is set to Site in VS. We can see the timer job which is deployed in the review job definitions in central admin. But, cannot see it in scheduled jobs. When we go to edit the timer job via review job definitions, and hit 'Run Now', we cannot see any messages in the error logs that we have programmed using PortalLog.LogString.

What could be the issue?

2

There are 2 answers

7
Dennis G On

Sorry - too long for a comment. Will edit to represent an answer later.

You have to clarify quite a few things here: "Under Site Collection we can see that it is deployed and activated" - you mean you have a site collection feature to deploy a timer job? Timer jobs are installed at farm level, hence it should be a webapp/farm feature.

PortalLog.LogString is for internal use only: PortalLog.LogString method

Did you try debugging the timer job? As it is correctly deployed to "job definitions" and you can click Run Now everything looks good so far. You only have to attach to the SPTimerV4 (SharePoint Timer Job) for the breakpoints to be hit in your solution.

You should use different logging such as explained here: https://sharepoint.stackexchange.com/questions/55381/timerjobs-and-uls and before waiting for any logs to magically appear: Debug!

0
Jan Vanek On

It seems to me that there are two issues:

  1. You should use other way for logging LoggingService should be preferred way. Use WriteEvent to write to EventLog or WriteTrace to write to ULS log.
  2. Running job. Be sure that Owstimer.exe service on all web servers are restarted (can be done by this powershell script). I expect that you have correctly scheduled your job either in your powershell script or in your feature receiver.