On Monday 27 Feb 2012, Amit Sharma wrote:
> Thanks!
>  
> The below is now working manually as well as via crontab. >> is
> required so that log can be maintained. 
> #!/bin/bash
> # Script to check exim mailq at a specified interval
> date >> /adminscripts/logs/eximcount
> Counter=`/usr/sbin/exim -bpc`
> echo $Counter >> /adminscripts/logs/eximcount
> if [ $Counter -gt 0 ]
> then
> cat /adminscripts/logs/eximcount |mail -s "Count of EXIM Mailq on
> Server"  a.sha...@example.com else
> exit 1
> fi

So it seems that the problem was the exim executables being located in 
/sbin... that seems to be the major change between this version and the 
previous one.

CC'ing the ILUGD mailing list so that the archives reflect the solved 
state of the problem.

Regards,

-- Raj

> From: Raj Mathur (राज माथुर) <r...@linux-delhi.org>
> To: il...@frodo.hserus.net
> Sent: Monday, 27 February 2012 12:41 PM
> Subject: Re: [ilugd] Shell script not running as expected via
> crontab, runs fine manually !!
> 
> On Monday 27 Feb 2012, Amit Sharma wrote:
> > #!/bin/bash
> > # Script to check exim mailq at a specified interval
> > echo `date` >> /adminscripts/logs/eximcount
> > echo `exim -bpc` >> /adminscripts/logs/eximcount
> 
> First of all, why the needless complexity?  You can just:
> 
> date >> /adminscripts/logs/eximcount
> exim -bpc >> /adminscripts/logs/eximcount
> 
> Also, should the first >> be a single > ?
> 
> > if [ `exim -bpc` -gt 0 ]
> > then
> > cat /adminscripts/logs/eximcount |mail -s "Count of EXIM Mailq
> > on Server"  a.sha...@example.com else
> > exit 1
> > fi
> >
> > 
> >
> > The above runs fine manually, however when I try to run it through
> > crontab (as root), it DOES run but /adminscripts/logs/eximcount
> > gets empty value. When I run it manually it is able to get the
> > correct count like 5, 10 etc.
> > What am I missing here? Please help.
> 
> Check the permissions on the script.
> 
> Remove the file before the cron runs and see if it gets created.
> 
> Check where root's mail goes -- that will help you track any cron
> errors.
> 
> Put full paths to all programs you execute in the script.
> 
> Let us see the whole cron command line.
> 
> Regards,
> 
> -- Raj

-- 
Raj Mathur                          || r...@kandalaya.org   || GPG:
http://otheronepercent.blogspot.com || http://kandalaya.org || CC68
It is the mind that moves           || http://schizoid.in   || D17F

_______________________________________________
Ilugd mailing list
Ilugd@lists.linux-delhi.org
http://frodo.hserus.net/mailman/listinfo/ilugd

Reply via email to