Quote:
Originally Posted by twantrd
Here it is
Code:
cat $LOGFILE | mail -s "Contents of my LOGFILE" user@company.com
-twantrd
|
Thanks a lot Twantrd..
am using the following script :
***********************************************************************
[root@oracle ~]# sh /root/test/tests/test/sysos.sh
LOGFILE=/home/oracrp/test/sysos.log
+ LOGFILE=/home/oracrp/test/sysos.log
echo "Logging system log at $(date)" >> "$LOGFILE"
date
++ date
+ echo 'Logging system log at Sat Dec 29 14:10:27 AST 2007'
# log vmstat. 3 * 5 second interval. Probably better than 1 second as it
# gives more time to average out the load analysis.
sar 1 5 >> $LOGFILE
+ sar 1 5
#/usr/sbin/sendmail
erp_webmail@ali.com.kw << EOM
#From

BA
#To:Yusuf
#Subject:$(date +%d-%b-%Y) Alert Log Error
#EOM
# make a blank line between commands to help readability.
echo "" >> "$LOGFILE"
+ echo ''
top -b -n 1 >> "$LOGFILE"
+ top -b -n 1
echo "" >> "$LOGFILE"
+ echo ''
w >> "$LOGFILE"
+ w
#netstat -tap >> "$LOGFILE"
echo "" >> "$LOGFILE"
+ echo ''
echo "" >> "$LOGFILE"
+ echo ''
#/usr/sbin/sendmail
erp_webmail@ali.com.kw << EOM
#From

BA
#To:Yusuf
#Subject:$(date +%d-%b-%Y) SYSOS
#EOM
cat $LOGFILE | mail -s "Contents of my LOGFILE"
erp_webmail@ali.com.kw
+ cat /home/oracrp/test/sysos.log
+ mail -s 'Contents of my LOGFILE'
user@company.com
***********************************************************************
am goin to have the above script in CRON which runs every 1 hour and sends a mail to the user. but since, the logfile is getting accumulated every time the script runs, so it sends the complete logfile contents to the user.. is there anyway,I can overcome this such that it should send only the last time executed commands output to the mail ?
Please help
Thanks
Yusuf