Hi,
I want to write a shell script which handle an oracle alert log so that when it changes month, the script generates a new file with month in the filename.
Thanks in advance.
Leim
Hi,
I want to write a shell script which handle an oracle alert log so that when it changes month, the script generates a new file with month in the filename.
Thanks in advance.
Leim
What do you mean by "when it changes month" ?
Do you just want to create a new file, say, "alert_Mon.log" on the 1st of every month, where Mon is the 3-character month abbreviation ?
if [ "$(date +%d)" == "01" ] ; then touch alert_$(date +%b).log; fi
tyler_durden
Thanks for reply.
The scenario is like:
Thanks in advance.
leim
ok Here is the script... You need to adjust according to you system some paths etc ...
Most of it will work once you make necessary changes.
------------------------------------------------------------------------------
ERRMESG="[ $(/bin/date) ]Something went wrong with Monitoring script.."
if grep -i Error /pathto/log/alert.log
then
ERRMESG="[ $(/bin/date) ] Errors in the logs $(grep -i Error /pathto/log/alert.log)"
echo $ERRMESG | mail -s 'Error in /pathto/log/alert.log' dba@whatever
else
ERRMESG="[ $(/bin/date) ]: The log file has been truncated."
fi
cat /pathto/log/alert.log >> "/pathto/log/alert.log.$(/bin/date +%b%Y)"
echo $ERRMESG >> "/pathto/log/alert.log.$(/bin/date +%b%Y)"
------------------------------------------------------------------------------
Do reply back with changes and working script ...