LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-26-2009, 07:22 AM   #1
kais1
Member
 
Registered: Dec 2008
Posts: 61

Rep: Reputation: 17
sending mails in script using mailx fails


dear all,

I have a cron runnign with the script below.

{code}

DT=`date +"%Y%m%d%H%M%S"`

rm -f /tmp/exp_pipe_full_SYST_infra

/usr/sbin/mknod /tmp/exp_pipe_full_SYST_infra p

nohup compress < /tmp/exp_pipe_full_SYST_infra > /backup/orainfra/soadhy/SYST_FULL_INFRA_"$DT".dmp.Z &

nohup $ORACLE_HOME/bin/exp system/SOA123@soadhy file=/tmp/exp_pipe_full_SYST_infra log=/backup/orainfra/soadhy/log/SYST_FULL_INFRA_"$DT".log full=y statistics=none &

mailx -s "SYST_INFRA_Backup_$DT" admin@jook.com.mg< /backup/orainfra/soadhy/log/SYST_FULL_INFRA_"$DT".log &

{code}

Export session is successfully completed..but the requirement is that it should send the log file to the user mail id.

But it is never working.. I can able to send mails through mailx from the command prompt..Please advise what is wrong with the script?


Kai
 
Old 07-26-2009, 08:18 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Hello kais1
Quote:
Originally Posted by kais1 View Post
dear all,

I have a cron runnign with the script below.

{code}[snip]{code}

Export session is successfully completed..but the requirement is that it should send the log file to the user mail id.

But it is never working.. I can able to send mails through mailx from the command prompt..Please advise what is wrong with the script?


Kai
Thanks for trying to use code tags. They need to be in brackets [] not braces {}.

Try changing the first line of your script to
Code:
#! /bin/bash -l
The -l (that's a letter l) makes the shell simulate a login environment, which cron does not do.

Best

Charles
 
Old 07-27-2009, 12:40 AM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
The first rule in cron is to always use the complete absolute path to all cmds/files used, as the default cron env is minimal.
eg

/usr/bin/nohup

Also, when using variables embedded in other strings, use parenthese to help the interpreter decide which is which eg
text_${varname}_moretext
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Sending mail by mailx command? lifeforce4 Debian 2 07-28-2008 06:00 PM
Sending mails sanjibgupta Linux - General 1 06-08-2006 06:40 PM
Sending HTML email via mailx grao75 Linux - Networking 1 11-08-2005 10:48 AM
Sending attachments using mailx wolfman423 Linux - Newbie 0 10-14-2005 09:27 AM
Composing and sending HTML mail from mailx stv_t Solaris / OpenSolaris 2 03-15-2004 04:23 PM


All times are GMT -5. The time now is 04:39 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration