Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programing the date -1

Status
Not open for further replies.

lblauen

Technical User
Aug 13, 2002
69
I have a script that I run everyday. It shows all errors in the errpt since midnight till now. I need it to show yesterday midnight till today. In other words true 24hours. Here is the script. Any help would be nice. Thanks in advance Lloyd.

echo "----- Display Error Report for past 24 hours"
echo
DATE=`date +%m:%d:%y`
START="`echo $DATE |awk -F\: '{print $1$2"0000"$3}'`"
ERRORS="`errpt -s $START`"
if [[ -n $ERRORS ]]; then
errpt -s $START | pg
else
echo "No errpt entries for today, `date +%D`"
fi
echo
echo Press Enter ;
read DUMMY ;
 
My favorite thing to do in this sort of case is to replace AIX's "date" command with gnu's date command. You can find it in the Bull archive, look for gnu's shell utilities.

gnu's version of "date" is hands-down great for doing things like "date --d 5 days ago" and things like that.

Also, why don't you format the "date" command directly instead of reformatting it with awk?

date +"%m%d0000%y"
 
Hi !!!
Why dont you use options of errpt ?

-s startdate Select entries posted later than date. (MMddhhmmyy)
-e enddate Select entries posted earlier than date. (MMddhhmmyy)
It is vey detaile din the man or just type errpt -Z to get all options !
 
I do use errpt's options but from a script that is hardcoded.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top