Using time conditions for scripting

I’d like to do something outside FreePbx to utilize the power of the time conditions/configurations. In other words, I’d like to set up a time group of 8:30pm daily and at 8:30pm execute a time condition that basically just runs a script under Linux.

Anything remotely like that already created?

Yes, “man crontab”.

May I please know how I can use crontab to trigger an event inside Asterisk? I really wasn’t clear in the initial post - I want to use the FreePBX modules to create and maintain these events

This ties back to another question that got asked today: specifically; how does one use the “API” that isn’t really well documented and some would argue isn’t really there.

There are lots of ways to do things from the Command Line in Asterisk. IFTTT, ARI, AMI, Call Files, and about 6 or 7 others that all allow you to interact with the FreePBX code base. In addition, there are actually FreePBX PHP routines that you can use within a cron script to trigger all sorts of events.

I was seeing the same thing. Problem is that each Time Condition depends on an outside event to trigger it, so my first thought was that I would use the cron to generate a connection to a specific inbound route every minute and that connection could go to Call Flow Control (to turn it off & on) and then from there to time conditions. A failing TC would Terminate Call while a qualifying TC would go to a Misc Application that was, in fact, a script.

But that all seems like hackery and, in general, I never assume I’m the first one to ever had an idea or a need.

We used this before for an issue:

#10 17 * * * /usr/sbin/asterisk -x “sip notify reboot-snom 5140”

Replace parentheses with whatever you want in asterisk

It’s an interesting idea, but one that would be really hard to get right. Also, some of your assumptions are actually not really the way the system works.

For example:

Time Conditions are internally managed, so there are no external events.

I’m not sure how you would accomplish this since that’s not really something you can do with an inbound route.

Call Flow Control is based on discrete events managed through (for example) interaction with the Asterisk Database instance. You can interact with these more easily using an “Asterisk Script” running within the quotes on an rasterisk -v “do something” where the do something can include database get or database set style commands.

You’re well served by not assuming these things. Thanks to the programming facilities built around Asterisk and through FreePBX, you seldom need to resort to the kinds of gymnastics you are thinking about. The AMI interface, for example, has the capability to do a lot of things that “look like” incoming or outgoing calls. Same with the Asterisk CLI. The facilities to do whatever it is you’re trying to do are all there, and probably implemented far more simply than your example suggests.

Tell us what you are really trying to do and I’ll wager at least one of us has already taken a run at something that’s a good start.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.