Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 10-08-2008, 09:04 AM   #1
LQ Newbie
Registered: Oct 2008
Posts: 1

Rep: Reputation: 0
Question 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

Old 10-08-2008, 07:07 PM   #2
Registered: Jan 2007
Location: Canton, MI
Distribution: CentOS, SuSE, Red Hat, Debian, etc.
Posts: 703

Rep: Reputation: 97
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


asterisk, cronjob, else, if, script

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Red Hat Hires Ex-SUSE Sales Exec to Run EMEA Channels LXer Syndicated Linux News 0 01-24-2007 03:03 PM
VoIP: Is it possible to run your own server, encrypt, etc. conn-fused Linux - Software 1 04-17-2006 09:06 PM
Use my old 56K modem to run SIP Server for voip tunasashimi Linux - Software 2 09-17-2005 10:29 AM
why do these cronjob not run? SheldonPlankton Linux - General 1 01-05-2005 08:01 PM
cronjob FastEddy Linux - General 1 04-12-2003 09:52 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:46 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration