# Job scheduler stop concurrent executions

**URL:** <https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785>\
**Category:** Questions\
**Created:** [December 12, 2022, 11:29am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785 "2022-12-12T11:29:54Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [December 12, 2022, 11:29am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/1 "2022-12-12T11:29:54Z")

</div>

If one have two jobs “sync all” and “sync new” that one don’t want to be running at the same time how do one do that. My first taught was create only one job and use parameter to control if “new” or “all” was to be executed. But if we want them to run on different intervals visual studio doesn’t like us adding two policies with the same name in app settings.

Litium version: 8.6.1

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 12, 2022, 12:04pm UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/2 "2022-12-12T12:04:40Z")

</div>

Run one job let’s say every hour and base the logic on time.  
Usually Sync all runs once per night time.  
If server time is let’s say 00.00 then run the Sync all else run Sync new.

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [December 12, 2022, 2:34pm UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/3 "2022-12-12T14:34:15Z")

</div>

That is a solution but then we need to make codechanges to changes the intervalls and while where looking at this we started to wonder how or if this is handled for the litium jobs.

If we have multiple servers are all these jobs necessary to run on every machine at the same time or how does that work?

“Litium.Auditing.CleanupScheduler”: { “CronExpression”: “0 45 0 1/1 \* ? \*” },  
“Litium.Customers.TargetGroups.CleanupScheduler”: { “CronExpression”: “0 13 0 ? \* \* \*” },  
“Litium.Products.PriceAgentScheduler”: { “CronExpression”: “0 45 0 ? \* \* \*” },  
“Litium.Sales.OrderMaintenanceScheduler”: { “CronExpression”: “0 40 0 ? \* \* \*” },  
“Litium.Websites.SitemapScheduler”: { “CronExpression”: “0 25 0 ? \* \* \*” },  
“Litium.Accelerator.PurchaseHistory”: { “CronExpression”: “0 30 3 ? \* \* \*” },

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [December 12, 2022, 3:17pm UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/4 "2022-12-12T15:17:35Z")

</div>

further if we would handle this with multiple web config and remove some of these jobs what are the default cronexpression for the litium jobs? We noticed that if we create a job and don’t want a job to run we can’t just exclude it from the config since it will use some default expression then

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 12, 2022, 3:30pm UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/5 "2022-12-12T15:30:13Z")

</div>

I think you get answer to all your questions on this [page](https://docs.litium.com/documentation/litium-platform/job-scheduler).

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [December 12, 2022, 7:54pm UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/6 "2022-12-12T19:54:52Z")

</div>

Looks like that page just confirms my questions. The appsettings override the CronScheduleJob cronschedule but at least with our own jobs it looks like if no cronscheduler set on the job it it self it looks like there are a default that the job defaults to since the job run even when not included in the appsettings.

So what is need to make the jobs not run at all is the question? Or are the litium jobs different so the won’t run if not included in appsettings?

The example om the page includes Litium.Auditing.CleanupScheduler is that a real example so Litium.Auditing.CleanupScheduler will be running on all machine at the same time?  
`[CronScheduler(` `"Litium.Auditing.CleanupScheduler"` `, DefaultCronExpression = ` `"0 0/1 * 1/1 * ? *"` `, Parameter = ` `"param1=text"` `, **ExecutionRestriction = ScheduleCronJobExecutionRestriction.None** )]`

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 13, 2022, 8:16am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/7 "2022-12-13T08:16:14Z")

</div>

You set this to none and they will run on all servers

> ScheduleCronJobExecutionRestriction.None

“So what is needed to make the jobs not run at all is the question? Or are the litium jobs different so they won’t run if not included in appsettings?”

Why would you want to turn off all platform jobs?

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [December 13, 2022, 11:56am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/8 "2022-12-13T11:56:31Z")

</div>

I understand what ScheduleCronJobExecutionRestriction.None will do. I’m asking if all the litium jobs are setup with ScheduleCronJobExecutionRestriction.None? if not, how they are configured and are there jobs that need or should to run on all servers?

I don’t want the platform jobs not to run at all i want to understand their behaviour. The example on the page includes example for `Litium.Auditing.CleanupScheduler` why would that one have ScheduleCronJobExecutionRestriction.None? is this just a bad example or should this job be running om all server?

And then we have the policys in the appsettings. Are you saying that the plattformjobs will not run at all if i remove the policys from appsettings? I ask because this is not the behavior if we create a custom job. In that case the scheduler looks to do a fallback to some default cornexpression.

that leads to the final question.  
If we want to stop a custom job we created from running how do we do that since removing it from appsetting policys doesnt stop the job from running.

---

<div class="post-metadata">

**Author:** ![steve.redstorm](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/steve.redstorm/32/14_2.png) [@steve.redstorm](https://forum.litium.com/u/steve.redstorm)\
**Post date:** [December 13, 2022, 12:47pm UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/9 "2022-12-13T12:47:55Z")

</div>

> [@Spotonkastebo](#):
>
> I understand what ScheduleCronJobExecutionRestriction.None will do. I’m asking if all the litium jobs are setup with ScheduleCronJobExecutionRestriction.None? if not, how they are configured and are there jobs that need or should to run on all servers?

As I understand platform jobs are running only on one server and not on all of them.

> [@Spotonkastebo](#):
>
> I don’t want the platform jobs not to run at all i want to understand their behaviour. The example on the page includes example for `Litium.Auditing.CleanupScheduler` why would that one have ScheduleCronJobExecutionRestriction.None? is this just a bad example or should this job be running om all server?

It is just an example to show if your own custom created job would be liked to run on all servers.

> [@Spotonkastebo](#):
>
> And then we have the policys in the appsettings. Are you saying that the plattformjobs will not run at all if i remove the policys from appsettings? I ask because this is not the behavior if we create a custom job. In that case the scheduler looks to do a fallback to some default cornexpression.

That depends if the job has a default cornexpression value on the class.

> [@Spotonkastebo](#):
>
> that leads to the final question.  
> If we want to stop a custom job we created from running how do we do that since removing it from appsetting policys doesnt stop the job from running.

Remove the default cornexpression from the class and it should not run anymore.

---

<div class="post-metadata">

**Author:** ![Spotonkastebo](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/spotonkastebo/32/717_2.png) [@Spotonkastebo](https://forum.litium.com/u/Spotonkastebo)\
**Post date:** [December 15, 2022, 9:13am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/10 "2022-12-15T09:13:34Z")

</div>

> [@steve.redstorm](#):
>
> > [@Spotonkastebo](#):
> >
> > that leads to the final question.  
> > If we want to stop a custom job we created from running how do we do that since removing it from appsetting policys doesnt stop the job from running.
> 
> Remove the default cornexpression from the class and it should not run anymore.

I will test again now i litium 8.7.1 but previously no cronexpression attribute in class resulted in that job is scheduled according to some default expression therefor removing it from appsettings did not stop the job from running.

---

<div class="post-metadata">

**Author:** ![patric.forsgard](https://yyz2.discourse-cdn.com/flex030/user_avatar/forum.litium.com/patric.forsgard/32/10_2.png) [@patric.forsgard](https://forum.litium.com/u/patric.forsgard)\
**Post date:** [December 20, 2022, 9:30am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/11 "2022-12-20T09:30:22Z")

</div>

We have tried to verify the bug that was created about this without luck.

You have detailed logging in the log file for the logger `Litium.Application.Scheduler.CronSchedulerJobSetup` that will describe the setup for each job that is registered or skipped.

Please double check these solutions and check the log:

- Rebuild/Reset IIS after apply new configuration
- Make sure appsettings.json file is configed correctly (maybe the configuration is overlapped by other appsettings files, eg: production, development, staging)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex030/uploads/litium/original/1X/12eddac3b8b661de1db86af10ac8151b571e6fb9.png) [@system](https://forum.litium.com/u/system)\
**Post date:** [January 17, 2023, 9:31am UTC](https://forum.litium.com/t/job-scheduler-stop-concurrent-executions/2785/12 "2023-01-17T09:31:00Z")

</div>

Closed on January 17, 2023, 9:31am UTC

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
