Getting Email from script

I am running a script from crontab and sending the output to another file. This is the statement in crontab:

45 23 * * * /dst/nikutst/clarity/lib/DSTRestartTest1.sh >> /dst/nikutst/clarity/logs/RestartTest.log

The script runs fine and sends output to the log file. But I always get a system generated email in unix that reads as follows:

From: Clarity Test <nikutst@wdc-niku-test-app1.dstsystems.com>
Message-Id: <201008240449.o7O4n2aL006667@wdc-niku-test-app1.dstsystems.com>
To: nikutst@wdc-niku-test-app1.dstsystems.com
Subject: Output from "cron" command
Content-Length: 315

Your "cron" job on wdc-niku-test-app1
/dst/nikutst/clarity/lib/DSTRestartTest1.sh >> /dst/nikutst/clarity/logs/RestartTest.log

produced the following output:

java version "1.5.0_16"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b02)
Java HotSpot(TM) Server VM (build 1.5.0_16-b02, mixed mode)

Anyone have any idea why I get this email and how to stop it?

This is a copy of the script:

#!/usr/bin/ksh
#DST Restart Test Application

HOME=/dst/home/nikutst
export HOME

. $HOME/.profile

EMAIL1="claritytecharch@dstsystems.com"
DATE=`date +%y%m%d`"_"`date +%H%M`
echo "Restarting the Test application for date " $DATE 

cd $DOMAIN_HOME

NUM=`find . -name "Test1.log" -exec grep -il "was shutdown" {} \; | grep -v grep | wc -l`
if [ $NUM -eq 0 ]
  then
     echo "Starting to shutdown Test1."
     ./stopTest1.sh >> Test1.log
  else
     echo "Server Test was already shutdown"
fi

sleep 30
echo "Sleeping for 30 seconds"
NUM=`ps -ef | grep nikutst | grep -v grep | grep -c Xms1536m`
if [ $NUM -gt 0 ]
  then
    echo "Clarity: Test1 environment did not shutdown successfully."
#    mailx -s "Clarity: Test1 environment did not shutdown successfully." $EMAIL1 < /dst/nikutst/bea92/user_projects/domains/Test/emptyemail.txt
  else
    echo "Server Test1 is down"
    cd $NIKU_HOME/logs
    mkdir $NIKU_HOME/logs/old_logs/app_logs/$DATE
    for file in app-niku.*;
      do
        mv $file $NIKU_HOME/logs/old_logs/app_logs/$DATE/$file
		echo $file "has been moved to old_logs/app_logs/$DATE directory"
      done
    cp $WL_DOMAIN/bin/Test1.log $NIKU_HOME/logs/old_logs/app_logs/$DATE/
	cd $NIKU_HOME/logs/old_logs/app_logs
    NUM=`find . -mtime +21 | wc -l`
    if [ $NUM -gt 0 ]
       then
          echo "The following files are over 21 days old and are being removed"
          find . -mtime +21
          find . -mtime +21 | xargs rm -rf
    fi
    cd $DOMAIN_HOME
    ./startTest1.sh
    echo "Starting up server Test1"
    NUM=`find . -name "Test1.log" -exec grep -il BEA-000360 {} \; | grep -v grep | wc -l`
    while [ $NUM -eq "0" ]
      do
        sleep 30
        NUM=`find . -name "Test1.log" -exec grep -il BEA-000360 {} \; | grep -v grep | wc -l`
        echo "Server Test1 is still starting up, trying again in 30 seconds"
      done
    echo "Test environment is up."
fi
echo " "

Hi.

Try adding this to the end of your cronjob:

2> /dev/null

Redirect all the errors to the either the same file (RestartTest.log) ir to empty file /dev/null as already told by scottn above.

45 23 * * * /dst/nikutst/clarity/lib/DSTRestartTest1.sh >> /dst/nikutst/clarity/logs/RestartTest.log 2>>&1

or

45 23 * * * /dst/nikutst/clarity/lib/DSTRestartTest1.sh >> /dst/nikutst/clarity/logs/RestartTest.log 2> /dev/null

Thank you that worked.

I didn't know you could redirect to two different files.