How to stop running task after certain time

How to stop running task after certain time

I have scheduled job every day but want to stop that job after certain time(eg.after 4hrs) on every day.

I believe you are looking for the TImeout setting of the Task:

1 Like

Agreed with @koryknick

@Mahesh7225: What time your job has been scheduled? How would you want to stop that? 4hrs after the execution or 4hrs after trying to run that job?

Thanks!

I tried this option but its not working

i have scheduled job every day at eg. 2pm and after job started it should automatically stop at 5pm on that day, but next day it should be start at 2pm as per schedule

@Mahesh7225: If you can share more details, why would you want the job to stop at 5pm ONLY? Does it run for 3hours from 2pm-5pm?

Also, if the requirement is to run at 2pm everyday, why don’t you go with Cron Schedule, I’m pretty sure you’re using the same, can you please confirm?

Here is the snap of the cron job for your reference:

Again, I’m not sure whether you have been using this or not, sharing it ahead of time if this is what you were looking for.

Also, to reiterate @koryknick’s point, timeout works every single time. Please ensure that timeout is in minutes so if you want the job to stop after 3hours, you put 180m in there.

I have never faced any issues with Timeout yet so you may want to try that out again and requesting you to share the screenshots of the what you have kept and email notification received even after timeout was set correctly but didn’t work (this is a very strange behavior and I’m inclined to believe that timeout will work 100% everytime)

Thanks!

Hi @Mahesh7225,

I don’t think is possible automatically to stop some process, but depending of your logic in the process you can control when to stop.

Example: You are querying some DB. You will have to make a copy of the same process, and also you will need to modify the process at the beginning to check if the time is 5PM (router or filter). After that at the end to call the copied process or original.

  1. The process is scheduled to start at 2PM.
  2. If the criteria is satisficed (5PM) then continue with the process, if not then end.
  3. Then you need to call the copied process or vice versa.

I hope this will help.

Thanks,
Pero M.