Quartz scheduler not executing job after app pool recycle (.Net) - quartz-scheduler

We have an intranet application hosted on IIS 8.0.
We have some web methods available which needs to be executed at certain time.
So, we have used the Quartz scheduler to schedule the job for executing web methods. In Application_Start event of global.asax, we have written the code to start the scheduler.
To keep the scheduler up and running the Application Pool should be in running mode always, so we have set the property startMode=“AlwaysRunning” and also, application should be started so we have set the application property preloadEnabled=“True”.
We are recycling the application pool at every 1740 minutes (29 Hours, the default time).
Here the question is:
If I have a job scheduled at 3:00 AM in the morning. My app pool is in running state.
I have browsed the application at 6:00 PM on one day before of schedule time.
As per the recycling time my app pool has been recycled at 2:00 AM and till 3:00 AM my application was not pinged but my app pool was in running state.
When Application Pool is recycled, the application pool will be started again (because of the property startMode=“AlwaysRunning”) but the process id if that worker process would be different.
Due to the recycle of app pool quartz had not executed the job as per the schedule. If I browse the application after recycling of app pool, then quartz will execute the job as per the schedule.
Can anyone help me on this at the earliest?
Thanks in anticipation.

If your IIS 8.0 is running on Sever 2012 OS, you will need to turn on 'Application Initialization' feature.
Please visit this link for more information.
Only after the feature in added, the property 'preloadEnabled=“True"' will be effective.
Please let me know if you are facing this issue on any other OS.
Hope this helps.

Related

How to setup High available active-passive postgresql which has scheduled job running on server

I am new to postgresql, I went through the Postgres documentation which provides details for the active passive server setup.
What I want is the scheduler in spring boot should run only on server which is pointing to active mode, and in passive mode the schedular should not run.
As soon as active goes down and passive takes over as new active, then jobs should start running on new server.
I just have 2 jobs , one runs each 5 mins and one runs everyday at 1AM.
Need help in achieving this

Should we unschedule Sling Jobs running within AEM after they are completed?

I am creating multiple SlingJobs on the fly using org.apache.sling.commons.scheduler.Scheduler OSGi service in AEM.
i.e. scheduler.schedule(Runnable, ScheduleOptions);
I have requirement that these Sling Jobs be run only once, so I am using ScheduleOptions.AT(Date date,int times,long period) ScheduleOptions Docs
And passing times=1 as a parameter.
(Also what is period parameter ?)
The Job successfully runs only once.
My question is am I supposed to keep a track of this Job by name and UnSchedule it using Scheduler.unschedule(String jobName) after it has finished running ?
Will completed SlingJobs that are not UnScheduled, consume memory in the AEM server ?
Will these completed BUT unscheduled jobs cause my AEM server to slow down and later on require some purge activity as maintenance?
According to https://sling.apache.org/documentation/bundles/apache-sling-eventing-and-job-handling.html#scheduled-jobs
Internally the scheduled Jobs use the Commons Scheduler Service. But in addition they are persisted (by default below /var/eventing/scheduled-jobs) and survive therefore even server restarts. When the scheduled time is reached, the job is automatically added as regular Sling Job through the JobManager.
I had a problem with a scheduled jobs before(they were triggered on the daily basis). When the server was restarted scheduled jobs wasn't un-persisted and a new job doing the same action was scheduled(job was scheduled on #Activate method). As a result, I got several jobs doing the same action at the scheduled time, so I had to unschedule them in #Deactivate method.
You may make an experiment and make sure that there is no duplicated jobs under /var/eventing/scheduled-jobs

Quartz scheduler stops working after some time in iis

When I publish my application to IIS server, quartz scheduler stop working after some time.In my local machine IIS server it works fine.
I need to perform some functionality every day at 11:55 pm.
By default, IIS recycles an application pool after some inactivity time. I guess this is your problem. The application will be just shutdown if nobody uses it.
While it is possible to make the application pool in IIS to run forever, it is still better to not schedule background tasks using web applications.
Use windows services or just simple Windows Task Scheduler for scheduling.
There are a couple of good solutions for scheduling background tasks with C# in .Net:
Topshelf
Hangfire
Here is a nice topic about using both solutions "Setting up windows service with Topshelf and HangFire"

Acumatica scheduler

This might be a strange question. Is there any way to make the scheduler stay active perpetually? I have a couple of instances, one on a server for testing and a development instance on my laptop. I setup some business events in both instances that accurately fire as designed. My question comes from the fact that the scheduler seems to stall if no one logs into the instance. Once I login to the instance with any id, the scheduler restarts and runs for about 12 hours and then stalls again. I thought it was only the test instance on the server, but I took a couple days off and my laptop instance also stalled. Is there a setting to overcome this? I know the assumption is that there will be users in the system in production, but what about over the weekend or holidays?
The schedule is run from the IIS worker process (w3wp) of the assigned Application Pool. Normally the worker process is started when the first web request is received.
If you restart the test instance of the server or your laptop instance you may experience this delay until someone logs in.
However, you can set the worker process to start automatically whenever an Application Pool starts.
Check your IIS configuration, look for the Application Pool assigned to your Acumatica instance and edit its Advanced Settings.
There you can change StartMode to AlwaysRunning.
Your app pool might be recycled. Check the following posts that can help you
How to know who kills my threads
https://serverfault.com/questions/333907/what-should-i-do-to-make-sure-that-iis-does-not-recycle-my-application

Azure - Mobile Services - run background task every 10 seconds

I have a .net backend mobile service in which I would like to run a task every 10 seconds. I can not use a scheduled job as they are limited to 60 seconds.
I have tried running the task in loop that aborts prior to the 60 second interval re-call, but that is not working out. The service seems to hang from time to time on the mobile device side/experience.
--
Does anyone understand how I can run a .net background task without using Scheduled Jobs?
Additionally, does anyone understand what happens when Scheduled Jobs call a service end point that has not returned or completed a previous call. Can this be detected?
The Scheduler that Mobile Services does not support what you are asking. Best bet is to convert your job to a WebJob that runs continually and do the 10-second wait yourself.
See WebJobs: https://azure.microsoft.com/en-us/documentation/articles/websites-webjobs-resources/