cron not sending external mails


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting cron not sending external mails
# 1  
Old 12-06-2011
cron not sending external mails

This script is to send a email if the IP adress is active
when i run this script it is working and sending emails to external users in different domains, but when this script is scheduled in a cron it is unable to send the emails
Code:
 
#/bin/sh
ifconfig -a | grep 192.168.0.1
if [ $? == '0' ];
then mail -s "subject" mail.domain.com < /home/user/mailmessage.txt
fi

So i used a while loop avoding cron, Below is the code, This is able to send the emails,

Code:
#/bin/sh
while :
do
ifconfig -a | grep 3.229.224.157
if [ $? == '0' ]
then 
   mail -s "CRITICAL!! PAN Credit Application Load Balancing Has Failed Over to MYUKSLCAP2LB002" -c \
  emailaddress@fqdn.com < \
   /home/smg_prod/mailmessage.txt
fi
sleep 60
done

But for the same code why it is not able to send emails when set via cron, checked cronlogs and found no errors, cron is executed as schedules, also checked messages no errors found

Last edited by robo; 04-12-2012 at 10:46 AM..
# 2  
Old 12-06-2011
Go with numerical comparator ..
Code:
if [ $? -eq 0 ];

# 3  
Old 12-06-2011
Check the hash-bang statement in the first line, it should be #!/bin/sh.
Does the user have privileges for running cron? Paste the cron entry.

--ahamed
# 4  
Old 12-06-2011
Did you check if it works when being run manually from a shell?
There is also missing a ! in the shebang:
Code:
#!/bin/ksh
...

# 5  
Old 12-06-2011
Quote:
Originally Posted by ahamed101
Check the hash-bang statement in the first line, it should be #!/bin/sh.
Does the user have privileges for running cron? Paste the cron entry.

--ahamed
Yes running as root

Tried changing the first line but still not working
# 6  
Old 12-06-2011
Paste the cron entry... crontab -l

--ahamed
# 7  
Old 12-06-2011
Quote:
Originally Posted by zaxxon
Did you check if it works when being run manually from a shell?
There is also missing a ! in the shebang:
Code:
#!/bin/ksh
...


i tried changing the code
Code:
#!/bin/sh

but cron is not sending the emails but when run manually from shell it is sending the mails i checked now

---------- Post updated at 09:29 AM ---------- Previous update was at 09:28 AM ----------

Quote:
Originally Posted by ahamed101
Paste the cron entry... crontab -l

--ahamed
Code:
26 * * * * /home/user/Loadbalancercheck.sh

particular entry for the script
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Solaris - Sendmail - Adding .com.gr in external senders e-mails

Hello Everybody ! I'm Harry from Athens Greece and i have a problem with my Sendmail 8.13.3 installed on Solaris SunOS ultra 5.10. The problem is that when someone sends to us an e-mail and his e-mail address is like : xxxx@xxxx.com, our e-mail server adds up in the senders address a .com.gr... (2 Replies)
Discussion started by: Mcasim
2 Replies

2. Solaris

Sending Mails to the Multiple Email Address

Hi All, I am pretty new to the mail service in Sun Solaris 5.10. If anybody help me in writing a script for the multiple recipient with subject and the body would be a helpful. Kindly help... Thanks in advance. :) Warm Regards, Pramod (5 Replies)
Discussion started by: Pramod_009
5 Replies

3. Solaris

Crontab schedule sending two mails insted of one

Hi all, We have scheduled one cronjob which is supposed to show output through mails about 15 systems's current status (whether its up or down) but it send two mails one about 10 system which arrive at 5.30(actual scheduled time) and in second mail about 5 systems. We want all these... (1 Reply)
Discussion started by: manalisharmabe
1 Replies

4. Solaris

Unable to send mails to external mailids from solaris 10

Hi, Iam not able to send mails from solaris servers to external mailid (gmail,yahoo).I am able to send mails to internal mailids with in network. Requesting you all to please help me to resolve this issue. Thanks in advance. Venkat (2 Replies)
Discussion started by: venkatasiva85
2 Replies

5. UNIX for Dummies Questions & Answers

Can't configure sendmail to send mails to external SMTP Server

Hi all,I know, that this is very common issue, but I can't find where is the problem... I have Solaris 10 installed.I want to send mail to external SMTP server, like:echo "letter body"| mailx -s "subject" test@test.comBut I donno what kind of changes I have to do in /etc/hosts and sendmail.cf or... (5 Replies)
Discussion started by: nypreH
5 Replies

6. UNIX for Dummies Questions & Answers

Sending mails to various users without hard coding the email IDS

Hi Can any one help me out ? I am trying to send an autogenerated mail with an attachment to bulk of users using 'MAILX' and 'UNENCODE' . I have used it as follows X " ( cat /sastemp/body.txt; uuencode Test.xls.gz Test.xls.gz ) | mailx -s 'Testing' ' abcd@yahoo.com , efgh@gmail.com ' " ... (9 Replies)
Discussion started by: manas6
9 Replies

7. Shell Programming and Scripting

error while sending mails through MKS

#!/bin/ksh email0="dummy@company.com" emails() { # mail Generation echo "Hi" | /mapimail -s "-(Test Mail)From Production- `date`" $email0; } emails i receive the following error IDispatch::new MSMAPI.MAPISession failed: 800401f3 at... (0 Replies)
Discussion started by: Vrgurav
0 Replies

8. IP Networking

Sending mails using plsql program

I am trying to send an email to personal id using plsql program. I have written a code in plsql using UTL_TCP package where opens the connections and then senda a mail. But when i execute the program mails are not being sent. I typed "mail" command on the unix box and got the below result... (5 Replies)
Discussion started by: amol_mudholkar
5 Replies

9. UNIX for Advanced & Expert Users

sending mails with attachment and also some text in mail body

Hi, Can some one help me with the syntax of the mailx that should send an attachment and also some text in the message body together. When I am using the following syntax it is not sending the attachment but only the message body. unix2dos -ascii $REPORTFILE | uuencode $PCFILE | mailx -s... (7 Replies)
Discussion started by: guptan
7 Replies

10. UNIX for Dummies Questions & Answers

Sending Mass mails

Hi Forum, I am extremely new to unix.Can somebody please help me out with the following: I am supposed to write a script that will ftp a file which is a .csv and conatins the following: Mail-id Path of file abc@xyz.com D:\xyz\abc.htm ash@sde.com ... (1 Reply)
Discussion started by: iyerdeepa82
1 Replies
Login or Register to Ask a Question