LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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, 06: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, 07:18 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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-26-2009, 11:40 PM   #3
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:32 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
Open Source Consulting | Domain Registration