This will sound weird but the command 'asterisk -r -x reload' fails to work when issued by Cron. But it works when I issue it from a bash session. What is not configured correctly? I need to refresh the configuration every a short amount of time. rom root@localhost.localdomain Wed Jun 15 18:42:00 2005 Date: Wed, 15 Jun 2005 18:42:00 -0400 From: root@localhost.localdomain (Cron Daemon) To: root@localhost.localdomain Subject: Cron <root@ashish> asterisk -r -x reload X-Cron-Env: <SHELL=/bin/sh> X-Cron-Env: <HOME=/root> X-Cron-Env: <PATH=/usr/bin:/bin> X-Cron-Env: <LOGNAME=root> /bin/sh: line 1: asterisk: command not found Any ideas?
Federico Alves wrote:> This will sound weird but the command 'asterisk -r -x reload' fails to work > when issued by Cron. But it works when I issue it from a bash session. What > is not configured correctly? I need to refresh the configuration every a > short amount of time. > > rom root@localhost.localdomain Wed Jun 15 18:42:00 2005 > Date: Wed, 15 Jun 2005 18:42:00 -0400 > From: root@localhost.localdomain (Cron Daemon) > To: root@localhost.localdomain > Subject: Cron <root@ashish> asterisk -r -x reload > X-Cron-Env: <SHELL=/bin/sh> > X-Cron-Env: <HOME=/root> > X-Cron-Env: <PATH=/usr/bin:/bin> > X-Cron-Env: <LOGNAME=root> > > /bin/sh: line 1: asterisk: command not found > > Any ideas?Login in as root, type in: type asterisk I get /usr/sbin/asterisk Change crontab (crontab -e) to use the full path. -- Linux Home Automation Neil Cherry ncherry@comcast.net http://home.comcast.net/~ncherry/ (Text only) http://hcs.sourceforge.net/ (HCS II) http://linuxha.blogspot.com/ My HA Blog
On 6/15/05, Federico Alves <sales@minixel.com> wrote:> This will sound weird but the command 'asterisk -r -x reload' fails to work > when issued by Cron. But it works when I issue it from a bash session. What > is not configured correctly? I need to refresh the configuration every a > short amount of time.Use the full path when calling asterisk. The cron environment is not like a standard shell in all respects. Chris
i think that is because asterisk is intstalled in /usr/sbin/ and you dont have that un your PATH env variable for cron. best regards On 6/15/05, Federico Alves <sales@minixel.com> wrote:> This will sound weird but the command 'asterisk -r -x reload' fails to work > when issued by Cron. But it works when I issue it from a bash session. What > is not configured correctly? I need to refresh the configuration every a > short amount of time. > > rom root@localhost.localdomain Wed Jun 15 18:42:00 2005 > Date: Wed, 15 Jun 2005 18:42:00 -0400 > From: root@localhost.localdomain (Cron Daemon) > To: root@localhost.localdomain > Subject: Cron <root@ashish> asterisk -r -x reload > X-Cron-Env: <SHELL=/bin/sh> > X-Cron-Env: <HOME=/root> > X-Cron-Env: <PATH=/usr/bin:/bin> > X-Cron-Env: <LOGNAME=root> > > /bin/sh: line 1: asterisk: command not found > > Any ideas? > > > _______________________________________________ > Asterisk-Users mailing list > Asterisk-Users@lists.digium.com > http://lists.digium.com/mailman/listinfo/asterisk-users > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- "Su nombre es GNU/Linux, no solamente Linux, mas info en http://www.gnu.org"
Does anyone know of a E911 interface I can get? Regards, Chris
Heres what I use; I have asterisk restart if the net is down and once a day just before 7am: crontab -e: 55 6 * * * /usr/sbin/asterisk -r -x "restart gracefully" >/dev/null 2>&1 5,10,15,20,25,30,35,40,45,50,55 * * * * /root/scripts/check_net /root/check_net #!/usr/bin/perl $net=`/bin/ping -c 02 google.com 2>&1 | /bin/grep -c 'unknown host'`; if ($net==1) { print `/bin/date`; print `/usr/sbin/asterisk -r -x "restart gracefully"`; } Federico Alves wrote:>This will sound weird but the command 'asterisk -r -x reload' fails to work >when issued by Cron. But it works when I issue it from a bash session. What >is not configured correctly? I need to refresh the configuration every a >short amount of time. > >rom root@localhost.localdomain Wed Jun 15 18:42:00 2005 >Date: Wed, 15 Jun 2005 18:42:00 -0400 >From: root@localhost.localdomain (Cron Daemon) >To: root@localhost.localdomain >Subject: Cron <root@ashish> asterisk -r -x reload >X-Cron-Env: <SHELL=/bin/sh> >X-Cron-Env: <HOME=/root> >X-Cron-Env: <PATH=/usr/bin:/bin> >X-Cron-Env: <LOGNAME=root> > >/bin/sh: line 1: asterisk: command not found > >Any ideas? > > >_______________________________________________ >Asterisk-Users mailing list >Asterisk-Users@lists.digium.com >http://lists.digium.com/mailman/listinfo/asterisk-users >To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users > >-- JD Austin Twin Geckos Technology Services LLC email: jd@twingeckos.com http://www.twingeckos.com phone/fax: 480.288.8195
Another note regarding a related issue: On Wed, Jun 15, 2005 at 02:47:00PM -0400, Federico Alves wrote:> This will sound weird but the command 'asterisk -r -x reload' fails to work > when issued by Cron. But it works when I issue it from a bash session. What > is not configured correctly? I need to refresh the configuration every a > short amount of time. > > rom root@localhost.localdomain Wed Jun 15 18:42:00 2005 > Date: Wed, 15 Jun 2005 18:42:00 -0400 > From: root@localhost.localdomain (Cron Daemon) > To: root@localhost.localdomain > Subject: Cron <root@ashish> asterisk -r -x reload > X-Cron-Env: <SHELL=/bin/sh> > X-Cron-Env: <HOME=/root> > X-Cron-Env: <PATH=/usr/bin:/bin> > X-Cron-Env: <LOGNAME=root> > > /bin/sh: line 1: asterisk: command not found/path/to/asterisk , as others have noted (or manually set PATH) However, if you leave asterisk in debug/verbose (verbose >=2? ) mode, cron jobs will start sending emails, because the command has generated an output. You could do something like: /usr/sbin/asterisk -r -x reload | egrep -v '^(Core debug|Verbosity) is at least [0-9]+' (Which is basically what I currentlly use in the wrapper for asterisk -rx on Rapid) But then the return status will be the return status of grep, which is not exactly what you want. cron will always send an email: if there is output: to give you the output. If there is no output: grep returns 1. For the record, the current init.d script on Debian simply runs "$DAEMON -rx 'reload'" on the command 'reload' Any ideas? -- Tzafrir Cohen | tzafrir@jbr.cohens.org.il | VIM is http://tzafrir.org.il | | a Mutt's tzafrir@cohens.org.il | | best ICQ# 16849755 | | friend