1


I have created custom timer job and successfully deploy it into SP. I see this timer job and feature on the lists. Job is being called every 10 minutes with status "succeeded". Issue is that Execute method is not being called. This is part of my code:

public override void Execute(Guid targetInstanceId)
    {
        System.IO.File.AppendAllText(@"C:\Temp\Timer.txt", "Copy Documents Timer Job Execute: " + DateTime.Now.ToString() + "\r\n");
    }

I'm writing logs to Timer.txt file in constructor too, and constructor code is being executed. Question: Why Execute method is not being called? What I'm doing wrong?

2 Answers 2

1

SharePoint timer jobs run in the context of the SharePoint Timer V4 service. Hence, SharePoint will not pick up changes for dll's loaded by this service, unless you either 1. Increment version of your assembly, or 2. Restart SharePoint Timer V4 service

0

Probably due to the timer process having insuffient rights to write to the directory. The constructor is being called when you create the timer job, which is done with a farm administrator account which is probably a local administrator too (so it does have rights to write).

Check the account the timer service runs under and see if that has sufficient rights to the folder.

7
  • Even when I delete write to file line, rest of code is not being executed. Basically this job is scanning some document libraries to find some documents. So there is not required any extra access level.
    – Neon
    Commented Feb 29, 2012 at 12:58
  • Could you check the ULS logs if there are any errors listed there? Execute is the only thing a job does, so it either works or it doesn't. If it doesn't work there's bound to be something written in the ULS logs.
    – Jasper
    Commented Feb 29, 2012 at 13:21
  • This is appearing when job is being executed: Site Enumeration Stack: at Microsoft.SharePoint.SPBaseCollection.GetEnumerator() at SP2010_CopyDocs.CopyDocsJob.Execute(Guid targetInstanceID) at Microsoft.SharePoint.Administration.SPTimerJobInvokeInternal.Invoke(SPJobDefinition jd, Guid targetInstanceId, Boolean isTimerService, Int32& result) at Microsoft.SharePoint.Administration.SPTimerJobInvoke.Invoke(TimerJobExecuteData& data, Int32& result)
    – Neon
    Commented Feb 29, 2012 at 13:36
  • 2
    restart SharePoint Timer service solved all issues.
    – Neon
    Commented Feb 29, 2012 at 14:19
  • 2
    LOL, yeah that's a requirement too ;) Your fresh GAC DLLs won't be loaded untill you restart the timer service.
    – Jasper
    Commented Feb 29, 2012 at 14:41

Your Answer

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

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