2
votes

I have developed a custom timer job for SharePoint 2013 in visual studio 2012 which sends email notifications. The issue is that it works fine on development server.

I have followed the following steps to debug it on the development server 1.) Deploy the timer job on respective site. 2.) Restart the timer service in services.msc 3.) Then is do attach to process OWSTIMER in visual studio. 4.) And finally Go to SharePoint 2013 Central administration->Monitoring->Review Job Definition and click on the respective timer job and say run now.

After doing this the breakpoint is hit in visual studio at the Execute() method. So in the development server it is running.

Now on the production server I cannot debug using visual studio so I have deployed the packaged solution(.wsp).

I can see the feature is activated in Site Collection Administration-> Site Collection Features.

Now on the production server I follow the following steps 1.)Restart the timer service in services.msc 2.)And finally Go to SharePoint 2013 Central administration->Monitoring->Review Job

Further to test whether the timer job is working on production server or not I had used PortalLog.LogString("Flow test1"); at the start of the Execute() method. Now this runs on the development server and I see the message in the SharePoint logs but on the production server I can't see "Flow Test1" in the logs after I click Run Now in central admin.

Can anyone suggest what is the issue and a possible solution?

3
Do you the job in the Job history list in CA? Is there any exception in ULS logs?tomasdeml
no I can see the timer job only in job defnitions, i can neither see it in job history nor in running jobs and also the last run time is N/Aluckydeveloper
And what about ULS, any exception? Did you check that all your assemblies are present in GAC?tomasdeml
No there is no exception in ULS nor there is custom message which I am trying to print in the logs. On the development server where the timer job is working there is no such dll in the GACluckydeveloper
Where do you deploy the DLL that implements the job? It must be deployed to the GAC to be loadable by the SP Timer service.tomasdeml

3 Answers

0
votes

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.
0
votes

Here are a few things to try:

  • Go to Central Administration and run the timer job from there. Then go to the job history page and check whether it finished successfully or not. If there was an error, you should see the error message from there. That will give you a clue on whats happening.
  • As Mazin said, restart the timer service in all servers. After deployment, the DLLs are cached by the process and you don't see your changes reflected.
  • Browse the SharePoint logs and search for an exception or error. You can narrow your search by selecting the timeframe on which your job ran. You can use the following PS script:

Get-SPLogEvent -StartTime "02/02/2014 11:00" -EndTime "02/02/2014 13:00" | Out-GridView

0
votes

As stated here it seems your job assembly is not deployed in the GAC. Verify that the assembly is present there.