I have an app which displays the latest scores in football games. Every 15 minutes, a cron runs to check if a game has started. If it has, another cron needs to start which runs every 30 seconds for the next 2 hours (this cron queries an API to get latest incidents for a game). Im on shared hosting with Plesk and there is no ssh access. Plesk appears to just offer very simple cron management to schedule the execution of a script every x minutes. What is the best solution for me?
Have the 30 seconds cron running every 30 seconds (also in times where there is no game) and check inside the script (which is run by this cron) if you are inside your 2 hour timeframe - if yes do the work else end the script
Related
I want to run cyclical tests in jmeter. I want them to run every day and than run for 10 minutes (every day for 10 minutes). How to do it?
For running test for 10 minutes there are following options:
In the Thread Group tick "Specify Thead lifetime" and put 600 into "Duration" field:
Or use Runtime Controller which allows setting how long its children are allowed to run
With regards to running the test every day, you can go for:
Windows Task Scheduler
Linux/Unix crontab
MacOS launchd
or you can put the JMeter job under the orchestration of a Continuous Integration server, any of them can run specified job on the schedule or basing on various different triggers, tracks job status (successful or failed), some of them provide performance trends
There are many ways to answer your (a bit too broad) question.
Here are some insights that could help:
to launch a JMeter test that last 10 minutes, you have to configure a job in JMeter with such a duration. Then you have to lear how to launch it via command line instead of via the graphical interface (see this answer for example)
to launch your JMeter test every day, you can use a Continuous Integration tool like Jenkins. In this tool, you will be able to create some jobs with a specific schedule (every day in your case) and a specific task (launch my JMeter test via command line)
Message [000] Request to run job Process*******DataSetLastTwoDays
(********) refused because the job is already running from a request
by Schedule 34 (Every Minute)
Could anyone help with the above error? This is an SQL Server Agent job that is meant to refresh every 2 minutes. After working for a couple of days, it stops running and causes other jobs depending on this to fail.
NB: It is a partitioning made in SSAS (Tabular mode).
I'm trying to execute a process to update my database, but the problem is that I set different RecurringJobs for it at different hours.
Today when I checked hangfire status, since yesterday that I instanced hangfire, I found the job should execute yesterday and the one task for today, both executed 30 minutes ago at the same time, and this has created duplicates in the database.
Can you help me with this?
If your problem is one of concurrency, you can solve it by running hangfire single threaded. Simply configure the number of hangfire worker threads on startup:
var server = new BackgroundJobServer(new BackgroundJobServerOptions
{
WorkerCount = 1
});
This will force hangfire to process queued jobs sequentially.
Alternatively, if you have the Pro version of hangfire you can control order using batch chaining.
I don't know if a worker can be considered as a thread.
Within a hangfire worker, single threaded code will be run by exactly one thread
This doesn't look like a concurrency issue as has been suggested. It's not completely clear what you are trying to do but I'm assuming you want the job to run at 7, 12:45, and 17:30 and had issues because both the 7am and 17:30 job ran at the same time (7am).
Based on the created time it looks like you created these around 14:30. That means the 17:30 job should have ran but didn't until the next morning around 7am. My best guess is this was hosted in IIS and the site app pool was recycled.
This would cause any recurring jobs that were supposed to run to be delayed until the app pool / site was started again (which I assume was around 7am).
Check out these documents on how to ensure your site is always running: http://docs.hangfire.io/en/latest/deployment-to-production/making-aspnet-app-always-running.html
If it's not an IIS issue something must have caused the BackgroundJobServer to stop monitoring the database for jobs until ~7:00am (server shutdown, error, etc).
Microsoft's documentation states:
Background tasks are meant to be short-lived tasks that do not consume a lot of resources.
It also says:
Each app on the lock screen receives 2 seconds of CPU time every 15 minutes, which can be used by all of the background tasks of the app. At the end of 15 minutes, each app on the lock screen receives another 2 seconds of CPU time for use by its background tasks.
I need to run a background task every two minutes to update my live-tile.
My app is a lock-screen-app.
Computation is within the CPU and network usage constraints
Can I create a permanent background task (e.g. something which polls a web service and pulls information, waits and loops) to create a OneShot TimeTrigger every two minutes or is there a better way of doing this?
My concern with the background task option is whether the runtime would deem the task inactive while it was sleeping and close it or something else like there's a limit on the number of times a live tile can be updated within 15 minutes...
Yes, if by long lived you mean under 25 minutes.
Time triggers cannot execute more frequent than 15 minutes. Creating a OneShot trigger that executes in 2 minutes is, that's an interesting idea and should work. Yes, background tasks can register other background tasks to keep this chain going. Should the user's machine be off when it execs it will queue later.
Having said that, updating your tile that frequently & using a background task is not a wise solution. Because, it is unreliable. Background tasks can be disabled, for one. But every 15 minutes, you are going to exceed your quota. Try using a Scheduled tile instead.
I have a couple of custom timer jobs that I have installed on my SP Foundation server. The server is running in Virtual Box, Server 08R2, it has been added to my domain and the time on the server appears in sync with the time on my local machine. The problem I have is that the time that the timer jobs say they are running is 2 hours behind what my server, local machine, domain say the time is. This is causing me some grief in my testing. I am not sure how it got into this state and I can't seem to find a way to get it back to the timer jobs being in synch with the server they are running on. Any ideas?
Edit:
Additional information. I added a logging statement into the timer job to output the result of DateTime.Now to the sharepoint log. The result of that call is the same as the server time, even though still in the central admin control the timer jobs appear as if they are running 2 hours behind.
Check time zones
Check day light savings
Check the locale's of all the site collections