-   Programming (
-   -   only run cronjob when asteriks voip gives 0 on channels (

1c3c0ld 10-08-2008 10:04 AM

only run cronjob when asteriks voip gives 0 on channels

i have set up a asteriks voip and add a cronjob to send the output of a specific command to my email after the cronjob shutdown -r now.
now i need a script that prevents the cronjob (reboot and email) from being executed if this command: asteriks -rx "show channels" states active connections(to prevent active calls being terminated)
the output of the command above(asteriks -rx "show channels") is as follows(if there are no calls)


channel                location          state    application(data)
0 active channels
0 active calls

i know this sounds complicated but what it comes down to that i basically need some kind of if and else statement in crontab

hope some 1 can help me with this


carltm 10-08-2008 08:07 PM

The easy way is to write a script. Something like this.
Then run this script from the cronjob. When the script is
run, it waits until after both channels are clear before

# @(#) reboot-voip reboot voip server after calls clear

until [ `asterisk -rx "show channels" | grep "^0 act" | wc -l` -eq 2 ]
sleep 5

shutdown -r now

All times are GMT -5. The time now is 07:53 PM.