Clear Across Kansas

cron-based Connections

cron-based Connections


This can be done in rpt.conf but I prefer to do it externally. There are actually examples in the /etc/asterisk/local directory.

You can learn some Linux doing this. Here are the steps. This looks long but is really simple.

Login to your Pi and select the shell – ADMIN menu 9

cd /etc/asterisk/local

Create this script in /etc/asterisk/local


Enter the following two lines…. use *73 instead of *3 for permanent connect

/usr/bin/asterisk -rx "rpt fun $1 *3$2"

Save it

Then create a disconnect script.


​Then enter the following two lines. Again *71 instead of *1 for a
permanent disconnect.

/usr/bin/asterisk -rx "rpt fun $1 *1$2"

​Save it…

Now make them both executable.

chmod 750
cdmod 750

What these do. The $1,2, etc. substitute parameters from the command line when you run the script. So if you typed this…

​/etc/asterisk/local/ 40000 40001

it would connect your 40000 to node 40001. The first node has to be a node on the server you are running the script on. Asterisk -rx “command string” simple executes what you would type at the client prompt.​

​You can (and should to test) run these manually at the command line as shown above substituting your from and to nodes.

Now automating. This is easy but you need to understand cron the Linux timing system to run jobs. It is best to Google cron. It consists of timing parameters followed by when is suppose to run when those parameters are met.

So using the connect and disconnect scripts here is how you would make a script. Lets suppose you want to connect node 40000 to node 40001 at 9AM and disconnect at 10PM. All times are 24 hours in cron.

To edit the cron table do:

crontab -e

This puts you in the nano editor. You will see previous lines there. DO NOT alter them. cursor down to a blank line and enter your new line(s).

00 09 * * * /etc/asterisk/local/ 40000 40001

This says connect at 0900 (9AM – Minutes first then hours) node 40000 to node 40001

Now we can enter our disconnect line.

00 22 * * * /etc/asterisk/local/ 40000 40001

This says disconnect at 2200 (10PM) node 40000 from 40001.

Of course all of this is example to show how you make scripts and how you would run them at specific times.

The cron entries designated by * if not used (spaces between them) are:

*minute hour dom month dow * DOW – day of week is 0 Sunday to 6 Saturday.

So in the above example a cron entry like this:

15 20 * * 1 some_command

would execute the command at 8:15PM on Monday.

You can modify the scripts as you see fit. For instance if you want to specify the full command in the cron you could make a script called

It could look like this:

/usr/bin/asterisk -rx "rpt fun $1 $2"

the the cron would look like this –

00 09 * * * /etc/asterisk/local/ 40000 *340001

​Experiment – its fun!​

*73 Doug*