Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cron Job not emailing root 1

Status
Not open for further replies.

Tranbo

IS-IT--Management
Apr 14, 2010
75
0
0
US
hi, I have serveral cron jobs in the crontab -l but only a few will sent me email log. some of these log belong to custom scripts that run nitely....like back up to tape. 1 of these script is just copy a folder files to another....but I it is never send me the email log ...how do I turn it on for this script to email me the result log?

Thank-You for your help.
 
If your script writes something to stdout or stderr then the result will automatically emailed.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
but I it is never send me the email log
You may put set -x in the script just before the copy ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I just don't know how to made this happen. my current script is below

=========================================================

umask 000
PATH=/usr/bin:/bin:/:.
export PATH
cd /tmp
DATE=`date '+%D %R'`
copy -mor /u /u1
diff -r /u /u1 > /tmp/n1

sleep 3

> /tmp/n2

OK="COPY BACKUP OK "$DATE
NOTOK="COPY BACKUP NOT OK "$DATE

diff n1 n2 1> n1n2 2>> n1n2

if [ -s n1n2 ]
then

echo "$NOTOK\n\n"
exit
 
Which email did you expect ?
What is the crontabs line launching this script ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I would like to have it email to root mail box


crontab -l

30 0 * * * /usr/bin/nitecp #Copies /u to /u1


 
I would like to have it email to root mail box
To email WHAT ?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 

The intent of this script is to make copy dir /u to /u1

once done, do dir compare and email root the finding.

I got this log email everyday and would like to have something like it:

From unix!uucp Fri May 20 23:45:02 2011
From: UUCP administrator <uucp@unix>
X-Mailer: SCO OpenServer 6.0.0 Mail
To: uucp@unix
Subject: uuclean ran; /usr/spool/uucp du
Date: Fri, 20 May 2011 23:45:01 -0700 (PDT)
Message-ID: <201105202345.aa04209@unix.>
Status: RO

2 /usr/spool/uucp/.Admin
2 /usr/spool/uucp/.Corrupt
2 /usr/spool/uucp/.Log/uucico
2 /usr/spool/uucp/.Log/uucp
2 /usr/spool/uucp/.Log/uux
2 /usr/spool/uucp/.Log/uuxqt
12 /usr/spool/uucp/.Log
4 /usr/spool/uucp/.Old
2 /usr/spool/uucp/.Sequence
2 /usr/spool/uucp/.Status
2 /usr/spool/uucp/.Workspace
2 /usr/spool/uucp/.Xqtdir
 
You may try something like this:
Code:
...
copy -mor /u /u1
diff -r /u /u1 >/tmp/n1 2>&1
if [ -s /tmp/n1 ]
then
  echo "$NOTOK\n\n"
else
  echo "$OK\n\n"
fi

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Ok, I got the script edited and working good. How do I schedule the crontab to run it right way for testing?
 
man at

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Got it to work now

Thank-You So Much!!!

========================================================

# at -m -f /zscript/test2 now
job 1323445713.a-2239:0 at Fri Dec 9 07:48:33 2011
# mail
SCO OpenServer 6.0.0 Mail Type ? for help.
"/usr/spool/mail/root": 1 message 1 new
>N 1 cron Fri Dec 9 07:48 23/662 Output of one of your cron
&
Message 1:
From unix!cron Fri Dec 9 07:48:34 2011
From: Cron daemon <cron@unix>
X-Mailer: SCO OpenServer 6.0.0 Mail
To: root@unix
Subject: Output of one of your cron jobs
Date: Fri, 9 Dec 2011 07:48:34 -0800 (PST)
Message-ID: <201112090748.aa02255@unix.>
Status: R

examine directory /u/linux
copy file /u/linux/.profile
copy file /u/linux/.inputrc
copy file /u/linux/.lastlogin
examine directory /u/linux/.ssh
copy file /u/linux/.ssh/authorized_keys
COPY BACKUP OK 12/09/11 07:48




*************************************************
Cron: The previous message is the standard output and standard error
of the following cron job, executed on your behalf:
1323445713.a-2239:0
&
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top