LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (https://www.linuxquestions.org/questions/linux-server-73/)
-   -   Shell script not running correctly using CronJob (https://www.linuxquestions.org/questions/linux-server-73/shell-script-not-running-correctly-using-cronjob-4175585011/)

mahi_nix 07-19-2016 06:32 AM

Shell script not running correctly using CronJob
 
Hi Folks,

I have a shell script to check mail queue and sent email if it reaches to critical level. Please find shell script as below.

Code:

#!/bin/bash
if [ `/usr/local/bin/exim -bpc` -ge 10 ]
then echo "MAIL queue at CRITICAL LEVEL `/usr/local/bin/exim -bpc`" | exim -v -odf user@domain.com
else
:
fi

I have schedule this script in cronjob to run every half an hour and sent mail queue status on my email ID. If i run this script manually it works and sends email to me but when it runs through cronjob it does not sends me any email.

When i checked cronjob logs it shows that this script schedule ran on the scheduled time.Please find cronjob configuration as below.

Code:

*/30    *      *      *      *      /bin/sh /root/bin/mail_queue.sh
can someone help me to find the solution.

Regards,

Emerson 07-19-2016 06:34 AM

You need to use full path to every command, or set the $PATH so the commands can be found.

mahi_nix 07-19-2016 07:24 AM

Hello Emerson,

It works with the full command path for exim -v command.

Thanks for your instance support and help. I appreciate it.

Regards,


All times are GMT -5. The time now is 05:15 PM.