0

We have created a custom timer job in VS2012 farm project.

The scope is set to Site level and the project is deployed at GAC.

Using VS2012, we can deploy the project and see it come up in the Job Definitions, we can hit RUN NOW and the timer job gets executed (it adds an item to a list).

However, when we package and install & activate the same project using PowerShell and hit RUN NOW nothing happens (time job does not execute). If we attach debugger to OWSTimer and then hit RUN NOW, then the timer job gets executed. What is happening? Why is it working only when we use VS and attach debugger to OWSTimer.exe?

We have logged in to the site and installed the package (PowerShell) using farm admin account.

Foll. is my PoweraShell script: (run as admin)

 $oUrl="http://mysite:7676/" 
     $solutionPath="C:\soln\"
    $solution="sampletimer.wsp"
        $path= $solutionPath + $solution 
        Add-SPSolution -LiteralPath $path
        install-spsolution -Identity $solution -GACDeployment -Confirm:$true  Enable-spfeature -identity "sampletimer_MyTimerJobFeatureEventReceiver" -confirm:$false -url $oURL

Our timer job is set to scope of SITE, we have packaged the wsp and installed & activated via PowerShell. Then, if we click on RUN NOW then it just wont execute its program (it is supposed to insert an item into a list). However, if we attached VS debugger to OWSTimer.exe, then hit RUN NOW, the timer job code gets executed and list items appears.

This is very confusing as to why SharePoint is behaving like this.. What must be causing this?

1
  • 1
    Have you restarted the Timer service?
    – user2536
    Feb 5, 2014 at 10:15

4 Answers 4

1

Try the following,

  1. Restart the timer service in services.msc

  2. Check your web application feature once after deployment.

15
  • what do you mean by Check your web application feature once after deployment. It shows ac active. Yet, under job defn, I cannot see the timer job..
    – variable
    Feb 5, 2014 at 10:22
  • try to de-activate and activate again after deployed the timer job with web application scope. Check if it throws any error.
    – Thangaraj
    Feb 5, 2014 at 10:35
  • it throws error if I try to deactivate. Foll. are deatails: Sorry, something went wrong Object reference not set to an instance of an object. Technical Details Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 0a3d719c-8659-80de-156d-1ed375e0df19 Date and Time: 2/5/2014 4:11:56 PM
    – variable
    Feb 5, 2014 at 10:42
  • 2
    ok then retract your solution --> then do IISRESET --> Rebuild it --> Deploy. If possible try setting the following properties in event receiver feature as ActivateOnDefault="false" AlwaysForceInstall="TRUE".
    – Thangaraj
    Feb 5, 2014 at 10:47
  • When I deploy it works all good; and shows up in the job defns.. But, when I package it and install the wsp it using PowerShell, it wont run, neither show up in job defn.
    – variable
    Feb 5, 2014 at 10:49
2

I vaguely remember encountering something like this in the past, and whilst the details escape me, I think that adding the -Force parameter to Install-SPSolution resolved the issue. I think this was in relation to features rather than timer jobs, but it might be a starting point.

0

You have to debug the feature activated, attach vs to this and you will see the error, when you activate a feature via powershell it executes under the context of a different user than if you activate it via central admin, so that might probably the reason.

1
  • After packaging the WSP and installing and enabling via PowerShell, when we hit RUN NOW, the timer job does not execute(it is supposed to add an item to a list). However if we attach debugger to the OWSTimer.exe, and then hit RUN NOW, the timer job executes (it does add an item to list). Why is this.?
    – variable
    Feb 5, 2014 at 11:21
0

Check uls log, find that job title. There could be an error or message. It happened to me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.