Fetching Action end timing & running specific action

Is there any option to capture end time of an action & calculating it with start time to check how much time we left for that particular action & on basis of output running another task.

Requirement is to run an task which is part of a baseline once all patches deployed & before starting of this particular task it will calculate the timing of action & if found 30 or 50 remaining from 2 hr window, the task will be executed.

any suggestion please