Using a route for a limit time


I wonder if there is a way to limited a route for a limited time

ex :
my dialplan is :
exten => s,1,dial(sip/${EXTEN}@xxxxx) -> Route 1
exten => s,2,dial(sip/${EXTEN}@yyyyy) -> Route 2

I am using 2 routes, depending on the availability.

Now, I wish to use the first route ONLY for 5 hours ( and no more )
( then the question is : Should I cut the current com after 5 hours or should I leave the existing call)
After 5 hours on this 1st route, I will only use the route N# 2 only

  • How can I put such a timing condition ?

thanks for your help


Try using the GotoIfTime(times,days_of_week,days_of_month,months?label) application. … ECT-3.html

Thank ambiorigx12,
Well, this is not really a time condition like a route opened on Friday and not saturday, but more… a call duration…

Is there another way to get a call duration ?

Or should I have the time before the call, and have the time after the call, then increment a counter,etc,etc,… ??
Sounds to be really heavy for just a call duration…?!?


I read the original question as being about time of day, as well. I’m still not completely clear what you are trying to achieve.

Normally people want a hard cutoff after a certain number of hours per month, and the problem arises that you cannnot revise time limits down after a call has started. However, I don’t think that is what you are trying to do.

I think you need to provide more context on the big problem. See


OK, I explain…

My dialplan is :
exten => s,1,dial(sip/${EXTEN}@xxxxx) -> Route 1
exten => s,2,dial(sip/${EXTEN}@yyyyy) -> Route 2

So, first I want to use the provider xxxxx
THEN, if I cannot place the call with xxxxx ( for any reason ), I want to use yyyyyy

Now, I have a route, via our PSTN line, which is free for 5 hours and very good quality, etc…( for exemple )…
So, my dialplan is still :
exten => s,1,dial(sip/${EXTEN}@xxxxx) -> Route 1 -> for the PSTN line
exten => s,2,dial(sip/${EXTEN}@yyyyy) -> Route 2
exten => s,2,dial(sip/${EXTEN}@ttttttt) -> Route 3

But this time, I want to use Route1 WITH my PSTN line ( I have a gateway for that)
BUT, I want to use this ROUTE1 only for 5 hours…
THEN, I want to use ONLY Route2 or Route3

So, I need to make understand the Asterisk server, that after 5 hours of use of the Route1, I want to use Route2 and Route 3 only
Now, if a communication is engaged, I agree, I would prefer NOT a hard cut… that would be quite nasty for our customers… :smile:

This is absolutely independant of the day of the week or the time of the day
That’s why I wonder if there is a way to get a duration call of a communication ?


People who try to do real time limits read the CDRs in the h extension. You will need to think about locking.

OK thanks… I will google it and se how to use it properly :smile: