System Administration
cancel
Showing results for 
Search instead for 
Did you mean: 

Output to log and the sent using sendmail

 
SOLVED
Go to solution

Output to log and the sent using sendmail

I am a newbie to HPUX and have a simple scripting question.

I have a below crons which outputs to a log file.

Question 1: Is this correct syntax to output to a file?
00 00 * * 1-5 /globus/bnk/bnk.run/scr/senddrbkup.sh 2>&1 1>/usr/local/tools/mia/log/GlobusZCopy.log

Question, how would I script this to send to an email using sendmail?

Thanks for any kind of help.
7 REPLIES
Solution

Re: Output to log and the sent using sendmail

The correct order is most likely:
============================================================
/globus/bnk/bnk.run/scr/senddrbkup.sh > /usr/local/tools/mia/log/GlobusZCopy.log 2>&1

Send stdout to that file, then send stderr to that same file.

>how would I script this to send to an email using sendmail?

mailx -s "some subject" somebody@xxx.com < /usr/local/tools/mia/log/GlobusZCopy.log
Kapil Jha
Honored Contributor

Re: Output to log and the sent using sendmail

Its OK and if you don want the error in log files the
/globus/bnk/bnk.run/scr/senddrbkup.sh > logfile 2>&1

to send mail, with log file output

mailx -s subject id < logfile

BR,
Kapil+
I am in this small bowl, I wane see the real world......

Re: Output to log and the sent using sendmail

What would be the syntax if we were using sendmail instead of mailx.
Thanks
Vishu
Trusted Contributor

Re: Output to log and the sent using sendmail

you can use as

# sendmail "email address" < "file path"

Re: Output to log and the sent using sendmail

>What would be the syntax if we were using sendmail instead of mailx?

Any particular reason why you want to use sendmail directly?
sendmail(1M) says: sendmail is not intended as a user interface routine.

Re: Output to log and the sent using sendmail

Dennis,
Sorry for such a LATE response. My boss insists in using sendmail. He swears by it. Then he questions me why he is getting system alerts 2 days later =)
Michael Steele_2
Honored Contributor

Re: Output to log and the sent using sendmail

cat file | mailx -s "SUBJECT" you@domain.com
sendmail you@domain.com < file
Support Fatherhood - Stop Family Law