1751972 Members
4544 Online
108784 Solutions
New Discussion юеВ

cron still sends e-mail

 
SOLVED
Go to solution
Don Spare
Regular Advisor

cron still sends e-mail

I have a number of cron jobs run by user 'oracle' that are used to do the daily maintenance. One in particular is sending output to the 'oracle' e-mail queue even though I have it re-directed to a log file as follows:
5,20,35,50 * * * * /dba/dba/maestro/compress_arch.sh >> /dba/dba/log/dwprod01/compress_arch.log

Can anyone tell my why this is still sending output to the e-mail and how can I stop it? Since this job runs every 15 minutes it builds up quite a queue of messages which I must delete manually.
3 REPLIES 3
linuxfan
Honored Contributor
Solution

Re: cron still sends e-mail

Hi Don,

Are the emails only for the failed job?

Try adding a "2>&1" at the end of the cron job.
what this will do is send both the STDOUT and STDERR to the log file

-HTH
Ramesh
They think they know but don't. At least I know I don't know - Socrates
Sachin Patel
Honored Contributor

Re: cron still sends e-mail

Hi Don,
Check script compress_arch.sh it might have mailx command running inside the script.
Or If script prints anything on standard output then cron will sends email automatically. so use 2>&1 at end of your cron line.
5,20,35,50 * * * * /dba/dba/maestro/compress_arch.sh >> /dba/dba/log/dwprod01/compress_arch.log 2>&1

Sachin


Is photography a hobby or another way to spend $
Don Spare
Regular Advisor

Re: cron still sends e-mail

Thanks, Ramesh. I knew it had to be something simple. As I looked through my crontab file I noticed that I had added the output redirect to other jobs to solve this problem.