Parse.com: stop background job at 14 minutes - background

How can I stop a background job at 14 minutes or after?
I basically have sub queries that can last 15 seconds Max and I'd like to stop them at 14m 15sec maximum so I can make sure they all completely terminate. I don't know how to implement a timer on a background job

Related

Batch is taking 7-15 minutes to processing 50k records

I am trying to fetch 50k records using SAP Query connector and send it to S3. but it is taking 7 minutes to process 50 k records in batch.It is taking time at the time at loading phase for instance. I have put S3 to aggregator. Still facing issue and also for next 50k records batch is taking 15 to 16 minutes and next records 30minutes. Can anyone help.
enter image description here

CloudWatch In alarm state end

I want an alarm, that if it detects 3 occurrences in a range of 5 minutes, it launches an alarm.
Therefore:
If an alarm occurs, I understand that it must be before the time of first occurrence + 5 mins.
And that the state of alarm lasts until the time of the 3rd occurrence + 5 mins. (Bearing in mind that after the 3 occurrence there is no more)
Therefore, having my current configuration, I don't understand why the alarm state lasts so long.

Setting an Individual Hangfire Job to Have Longer Auto Retry timeout Value

I know Hangfire has a logic of auto re-queue jobs that have been running for >30 minutes.
But I have a job that will run for >30 minutes and I don't want any auto-retry.
Meanwhile, I have some jobs that need auto-retry.
Is there anything to configure an individual job's auto-retry-timeout value?
e.g. I manually configure job A's value to 24 hours so it can run for 24 hours without any timeout retry while other jobs remain the same and are auto re-queued when their execution time exceeded 30 minutes.

Background Threads in Horizontally Scaled Application

The current situation is that I have an application that scales horizontally with one SQL database. Periodically, a background process is ran but I only want one invocation of this background process running at a time. I have tried to accomplish this by using a database row and locking but I am stuck. The requirement is that only one batch job should have successfully completed per day.
Currently I have a table called lock which has three columns: timestamp, lock_id, status. Status is an enum that has three values 0 = not running, 1 = running, 2 = completed.
The issue is that if a batch job fails and status is equal to 0, How can I make sure that only one background process will retry. How do I guarantee that only one background process is running in the retry scenario?
In an ideal world, I would like to do a SELECT statement that checks for the STATUS in the locking table, if status is = 0 meaning not running then start the background job and change status to 1 = running. However, if all horizontally scaled processes do this at the same time, is it guaranteed that only one is executed?
Thanks!

Calculate total running time and pause time

Calculate total running time and pause time
I have table as shown in attached image.
Transaction Status meaning : 3= start, 6= pause, 5=stop
I need running time & pause time for batch run template id
Notes :
Transaction can be paused and resumed multiple times as shown in image
STOP can occure only once and can occur after the pause transaction or start transaction
if a transaction started but not paused and stopped system should pick up the current date to calculate
Here is my answer to very same problem. Please check this, and slightly modify by your needs :)