LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 07-19-2016, 06:32 AM   #1
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Rep: Reputation: 16
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,
 
Old 07-19-2016, 06:34 AM   #2
Emerson
LQ Sage
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~amd64
Posts: 7,661

Rep: Reputation: Disabled
You need to use full path to every command, or set the $PATH so the commands can be found.
 
1 members found this post helpful.
Old 07-19-2016, 07:24 AM   #3
mahi_nix
Member
 
Registered: Aug 2010
Distribution: CentOS, RHEL, Ubuntu,
Posts: 154

Original Poster
Rep: Reputation: 16
Hello Emerson,

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

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

Regards,
 
  


Reply



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
[SOLVED] Cronjob not running, however script it calls works ok JockVSJock Programming 5 09-16-2013 11:36 PM
Script not running through cronjob? NotAComputerGuy Linux - Newbie 28 07-10-2013 12:51 PM
[SOLVED] Cronjob - Shell Script Not Running rcrosoer Linux - General 5 05-22-2013 07:35 AM
script not running in cronjob dningale Solaris / OpenSolaris 2 08-14-2008 12:27 AM
script expression not running in cronjob dningale Solaris / OpenSolaris 2 08-13-2008 12:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration