I have a custom job. It works fine on staging server, after moving to production it is not working. It shows in Central Administration "Job Definitions" I can open it and click "Run now" but it has no effect = still is visible in "Job Definitions" and not visible in "Job History" or "Running jobs"

I have:

  • restarted OWSTIMER
  • iisresets
  • browsed ULS for info (no info)
  • checked event viewer (no info)

The difference between staging and production is that staging contains only one webapplication and production more.

Could it be that SPJobLockType.ContentDatabase is wrong here? Or is it something else?

Jobs code:

    public class PropagacjaDanychLekuJob : SPJobDefinition
        public const string JobName = "PropagacjaDanychLekuJob";

        private int _lekId;
        private string _numerKatalogowy;
        private string _wielkoscOpakowania;
        private string _stezenie;
        private double _cenaKatalogowa;
        private DateTime _zmianaOdDaty;

        public PropagacjaDanychLekuJob(string name, SPWebApplication webApplication, SPServer server, SPJobLockType lockType) : base(name, webApplication, server, lockType)

        public PropagacjaDanychLekuJob(SPWebApplication webApp) : base(JobName, webApp, null, SPJobLockType.Job)


        public PropagacjaDanychLekuJob(SPWebApplication webApp, int lekId, string numerKatalogowy, string wielkoscOpakowania, string stezenie, double cenaKatalogowa, DateTime zmianaOdDaty)
            : base(JobName, webApp, null, SPJobLockType.ContentDatabase)
            Title = "Aktualizacja po zmiane leku o Id " + lekId;

            _lekId = lekId;
            _numerKatalogowy = numerKatalogowy;
            _wielkoscOpakowania = wielkoscOpakowania;
            _stezenie = stezenie;
            _cenaKatalogowa = cenaKatalogowa;
            _zmianaOdDaty = zmianaOdDaty;


        public PropagacjaDanychLekuJob() : base()

        #region Overrides of SPJobDefinition

        public override void Execute(Guid targetInstanceId)
            SPWebApplication webApp = this.Parent as SPWebApplication;
            //SPListItem lek = webApp.Sites[0].RootWeb.Lists["Leki"].GetItemById(_lekId);

                                                         using (SPSite site = new SPSite(webApp.Sites[0].ID))
                                                             using (SPWeb web = site.OpenWeb())
//my operations



Execution in my event receiver:

PropagacjaDanychLekuJob job = new PropagacjaDanychLekuJob(properties.Web.Site.WebApplication,

                    SPOneTimeSchedule spOneTimeSchedule = new SPOneTimeSchedule(DateTime.Now);
                    job.Schedule = spOneTimeSchedule;
  • Have you verified that the value of webApp is correct? Also, did you solve this problem? I have a similar situation. – LFurness Apr 4 '13 at 18:33
  • I haven't exactly solved the problem, but I have checked all variables, logged it to sharepoint logs and was ok. You may try to add the user you need (in my case the application pool account) to Farm Administrators. – christof Apr 5 '13 at 9:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.