shell script to grep latest out of memory messages from log files
I have prepared script to grep out of memory messages from the log files. I have to modify script in such a way that it should always grep for latest out of memory messages from the logs.
var=`tail -10 file_name| grep -i outofmemory | sed -n '$p' | sed -n -e "s/.*\(OutOfMemoryError\).*/\1/p"`
The above command is not useful if logs are not getting updated.It will gep old messages. would like to mmodify above command in such a way that it should always grep for latest out ofmemory messages and not old messages.kindly guide.