Operating System - Linux
1753404 Members
6975 Online
108793 Solutions
New Discussion юеВ

cron script - unwanted e-mail generated

 
Raynald Boucher
Super Advisor

cron script - unwanted e-mail generated

Hello all,

I have this little script that is triggered by oracle's crontab on a redhat virtual server. The script works fine because I can verify results but it generates a Mail message every time it runs. I want to eliminate the Mail messages.

The following crontab entry was created by "crontab -e" as the oracle user:
"0-59/5 * * * 0-6 /u01/oracle/SCRIPTS/copy_archivelogs_to_nbcseprd_DR.sh > /dev/null"

The Mail message looks like:
Message 61:
From oracle@db13.xxx.ca Thu Jan 28 04:30:02 2010
Date: Thu, 28 Jan 2010 04:30:01 -0400
From: root@db13.xxx.ca (Cron Daemon)
To: oracle@db13.xxx.ca
Subject: Cron /u01/oracle/SCRIPTS/copy_archive
logs_to_nbcseprd_DR.sh > /dev/null
Content-Type: text/plain; charset=UTF-8
Auto-Submitted: auto-generated
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:
X-Cron-Env:

<<the system, the client represents that he or she is an authorized client.

Ce systeme ne doit etre utilise par des clients autorises. En continuant
d'utiliser le systeme, le client affirme qu'il est un client autorise.>>>

where the text that is shown between the <<< and >>> is the contents of the /etc/issue file that is displayed at logon time.

Questions:
1- Is the message generated by :cron: or by the :sh: command that is executed on the :find: command output?

2- How can I get rid of that mail message?
I still want to know if the script failed.

3- Can someone clearly explain the -exec constuct found in the :find: command?
I know it moves files to the MOVED_TO_DR but I have no idea where the "find-copy" comes from and what the + means.

Thanks

Rayb
3 REPLIES 3
Keith Bryson
Honored Contributor

Re: cron script - unwanted e-mail generated

Hi Raynald

try the following:
0-59/5 * * * 0-6 /u01/oracle/SCRIPTS/copy_archivelogs_to_nbcseprd_DR.sh >/dev/null 2>&1

This ensures that all output (stdout/stderr) goes to dev/null.

Hope that helps
Keith
Arse-cover at all costs
Raynald Boucher
Super Advisor

Re: cron script - unwanted e-mail generated

I thought about that but I wish to get mail when the script fails.
Won't that defeat that purpose?
Keith Bryson
Honored Contributor

Re: cron script - unwanted e-mail generated

Raynald

What is the function of this script? If you have a find statement within the script, then you should error-check and send an alerting email from the script itself. Why not post it here and we can make suggestions? You can obviously trap your script output to something else other than /dev/null, say for example:

0-59/5 * * * 0-6 /u01/oracle/SCRIPTS/copy_archivelogs_to_nbcseprd_DR.sh >>/tmp/script.log 2>&1

but you will then need another script to monitor your logfile (/tmp/script.log in this example). You can set a non-zero exit code when the script fails (on completion) and this return code is stored in the cron log, but again, you need another script to detect/monitor this.

All the best - Keith
Arse-cover at all costs