Script to terminate call


We are running Elastix version 2.4 which I think runs freepbx in background, so since there is no option via web panel of Elastix version 2.4 to achieve what we need so I have to ask it here as someone told me it will be possible via freepbx script if I add it in crontab of Linux.

Issue we have is that agents make very long duration calls, so we need a script to terminate all calls(for every agent) after 20 minutes of duration, and for agents who comes in evening shift after 6:00 to terminate their calls after every 30 minutes(as they are good guys and hangs up call properly). Also, if possible in the same script can we except any particular agent from this so he/she should not have any limits?

Can someone please provide me kind of that script? and will it work on Elastix version 2.4 if I make it via crontab of Linux?

Thanks in advance.


A simple cron job would be useless, it would run synchronously at specific times granular to one minute. Your calls are started randomly so how would the cron job know when to " channel request hangup " a particular channel? :slight_smile: ,

Your best bet is to set your call duration using the L option in your “outbound dial command options”, ref:

I would also suggest you replace Elastix with a supported FreePBX system, who knows what they have changed in their “hacked” version of FreePBX?


Thanks for this, but we are already doing this via “Asterisk Outbound Dial command options” in “General” tab, specifying L(milliseconds). But this is terminating calls every 20 minutes anytime day or night… so I was looking into some script where we can say that this is not the rule for agents coming after 6:00 so they should have 30 minutes call duration limit not 20.

So, it would be looking like

(Existing calls >= 20 minutes & time = 9 to 6) than hangup OR if (Existing calls >= 30 minutes & time = 6 to 9) than hangup

I hope there should be a way to script this so it can run behind Elastix version 2.4 which does not have this functionality anywhere…

Also, if possible can we have a script where I can define only following country codes can which can call beyond 30 minutes otherwise all are 20 minutes anytime a day/night.


You could run a script via cron every minute and have it do all the logic… the sky is the limit if you know what you are doing. There is developer documentation at with php you can use our bootstrap and internal manager methods.

On a side note it is not good practice to arbitrarily terminate calls.

Perhaps refer to :-

in your case the Global variable is “DIAL_OPTIONS” (and perhaps “TRUNK_OPTIONS” for inbound calls) , it could be added to a custom “Time condition” call, but a reload would probably override it.