System Time Set using Radio DTMF

A means to set system clock with DTMF RADIO COMMANDS.

First I want to point out several things.
Read the warnings at the bottom.
This is not a perfect thing, but a framework to meet a end need.
You will likely need to make adjustments to it for your particular circumstance(s).

It was intended for Acid users who have no internet connection on their system but can be adapted to fit many situations.
While there are more than a dozen ways to do the same thing,
I chose this one to show to the group for the simplicity of implementation to those that are not as linux savvy, but have learned asterisk somewhat.

If you are in the US and have had the same system running for many years without updating the zoneinfo files, you should do that and copy the new timezone file to your /etc/localtime because the Daylight Savings Time that changed a few years ago (again) has probably been giving you some frustration on the time change twice or four times a year.  More info on that on the web:

SO, I am implementing this from the phone patch. Using the default dial to open the patch.

By default, (*6) +A+ HHMM is all the dtmf you would need to enter the time in 24hr format. Example *6A1345 will set the clock to 1:45pm

I chose ‘A’ as the dialing catch since it’s unlikely to be in your normal phone extensions and is intended for ‘no internet service’ installs set by RADIO.

If there are not 4 numbers to follow the “A”, it will fall through, otherwise it will say ‘the-time-is’, the four numbers you are setting, then pause for 10 seconds to allow you to hang-up ( *0 ) if you wish to cancel before it sets time and reboots your machine.

If you are trying to sync it to the second, enter it 15 seconds before the top of a minute (a 20 sec head start). Because asterisk always runs with a match as soon as it appears. So that would start running on the last/4th dtmf time digit (5th digit entered) after the phone patch prefix, not when you unkey the radio.

In extensions.conf  just under [radio]

exten = _Axxxx,1,Goto(set_time_clock|${EXTEN:1}|1)   ;set time, send to subscript without leading digit

(place the rest at the end of extensions.conf file….)

[set_time_clock]; by kb8jnm
exten =_X.,1,Wait(5)
exten =_X.,2,Playback(rpt/thetimeis)
exten =_X.,3,SayAlpha(${EXTEN})       ; Read back Dialed Number for time
exten =_X.,4,Wait(10)                  ; allow 10 seconds to hang-up (*0 ) if not correct
exten =_X.,5,System(date +%T -s \”${EXTEN:0:2}:${EXTEN:2:2}:00\”) ;format ‘HH:MM:00’ – 24hr format
exten =_X.,6,System(reboot)
exten =_X.,7,Hangup

Adjusting the timeclock on a live system can have unknown affect on things that are running  & relying on timers.

What is not a problem now could be a problem latter depending on your cron and sched settings for what is currently active on the system.

If you have much a time slippage in your clock, adjust it more often or when it gets 2 minutes or so out of time.

So at a minimum, shutdown links before adjusting the clock. My remedy for this was a reboot after setting.
I am thinking of you folks that have unconnected mountain top systems you can’t get to if a problem arises.
So, To avoid many unexpected problems that can occur in system timers mis-match, the system will reboot right after setting the clock.

I suggest you leave ‘REBOOT’ in place unless you have good reason to take it out. But you have been warned.

If you like it… great… if you don’t like it… make it better and shove it out to the group for others to improve on.
Probably better to hand the extension data off to a shell script, shutdown asterisk, set-clock, restart asterisk & exit. But not if you use cron for all your app_rpt and system scheduling needs.
But this is simple and with the full reboot, resets ‘all’ system timers before ‘any’ can be a problem. Unless you change that.