Scheduling Commands

Hi All,

I’m fairly new to Asterisk and have some things I’d like to achieve. I’m porting over some scripts from Lua/Freeswitch so I’ve got a couple of questions about a few things and how to do them in Asterisk.

I’m using PHPAGI and ConfBridge and would like to unmute a member in X seconds time. Is it possible to have another channel run a scheduled command to unmute another member? I understand that ConfBridge can accept CLI commands so I can run these via ManagerAction_Command to do something like;

“confbridge mute 1111 SIP/mypeer-00000001”

That works perfectly for my needs - however I don’t want to do it right away. I know FreeSwitch has a built in scheduler so you can run a command in +X seconds.

How would I go about this with Asterisk, is there anything built in? If not, does anyone have a solution that would work which isn’t too expensive/clunky?

Next question - is it possible to have Asterisk run an AGI script (or some sort of script) on Startup/Restart in order to achieve some set tasks that need to be done on engine startup?

Any help would be greatly appreciated, especially in the scheduling department.

Many thanks

Let me google that for you: Cron job.


/etc/rc.local

I understand that I could use a Cron Job for this and had thought about that but wondered if there was any built in facility to do so. So from within the AGI script would you do something like the following;

Do a System/TrySystem call and use a Cron Job to pass the command to the CLI, something like;
$agi->exec(‘TrySystem “asterisk -rx confbridge unmute 1111 SIP/mypeer-00000001”’);

This is what I was thinking, but wasn’t sure if was “correct” and thought that doing a system call back to the CLI may be quite “expensive”. Hence the query regarding built in or other solutions people may have found.

Also isn’t Cron limited to a minimum of 1 minute. How would you solve this if you needed to unmute in 20, 27, 34 seconds?

[quote=“ambiorixg12”][quote=“alpha_strike”]

Next question - is it possible to have Asterisk run an AGI script (or some sort of script) on Startup/Restart in order to achieve some set tasks that need to be done on engine startup?

Any help would be greatly appreciated, especially in the scheduling department.
[/quote]

/etc/rc.local
[/quote]

Sorry, I wasn’t very clear with my question here. Not when the system boots but when Asterisk itself starts. Such as when the service is started, run an AGI script. Again, I guess I could use the CLI and a cron job to run an AGI script?

My thinking here is if the Asterisk service stops uncleanly or someone issues a restart there could be database entries that need cleaning up. So when Asterisk is started, it would run a script in order to do that. I know it shouldn’t be an issue but I’m sure somehow that event will occur. Again, I’m just asking the experienced people how they would achieve this.