LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

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

Rep: Reputation: 0
Question only run cronjob when asteriks voip gives 0 on channels


hello,

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)

Code:
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

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

Rep: Reputation: 93
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
rebooting.


#!/bin/sh
# @(#) reboot-voip reboot voip server after calls clear

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

shutdown -r now
 
  


Reply

Tags
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 04:03 PM
VoIP: Is it possible to run your own server, encrypt, etc. conn-fused Linux - Software 1 04-17-2006 10:06 PM
Use my old 56K modem to run SIP Server for voip tunasashimi Linux - Software 2 09-17-2005 11:29 AM
why do these cronjob not run? SheldonPlankton Linux - General 1 01-05-2005 09:01 PM
cronjob FastEddy Linux - General 1 04-12-2003 10:52 PM


All times are GMT -5. The time now is 03:00 AM.

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