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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help over this

Status
Not open for further replies.

jaihelsing

Technical User
Mar 19, 2014
5
CA
thread271-1593376

I am working over a script to scan my log file for current date and if found print the file till end including the found line.

eg:[3/20/14 22:52:25:878 EDT] 0000014a SystemErr R 2014-03-20 22:52:25,878 SEVERE [com.ibm.ws.webcontainer.webapp] - SRVE0293E: [Servlet Error]-[engine]: java.lang.RuntimeException: Failure invoking transactional process 40280ef4-1d44-5120-011d-44518bcd0380.

Like in the above when it comes across 2014-03-20 it sud print the entire lines below it till end including the found line.

could you please suggest an AWK command to do so.
I have tried awk -v mydate="$(date +"%F")" '/mydate/{f=1}f' $FILE > temp.txt
but i am not able to get any output.
 
What about this ?
Code:
awk '/'$(date +"%F")'/{f=1}f' $FILE > temp.txt

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Yes its working...Thanks a lot!!
I have another query. I wana schedule a sh script to run after every 2 hours. Can i do it in any other way except using crontab.
Actually due to some securty reasons crontab funtion is blocked in our environment.
Is it possible?..Please suggest
 
jaihelsing said:
. . .
Actually due to some security reasons crontab funtion is blocked in our environment.
Is it possible?..Please suggest
And you want to bypass security?
What will the Chief Security Officer have to say about it?
[thumbsdown]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
i don't wanna bypass security.Its just that since that function is blocked was finding another way out.
Actually the crontab function is considered unsecured. To get the permissions from the client and get the crontab functional may take time.
So i thought if some one could help me out finding an alternate to crontab. Which will get my scheduling work done.
 
Code:
while :; do
  awk '/'$(date +"%F")'/{f=1}f' $FILE > temp.txt
  sleep 7200
done

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi,

Sorry i was out of station for a few days. Could you please explain me the above scripts. Will i not have to crontab this sh script?. how frequent will it run and is there no need to manually run it.??
My requirement is to run it every 2 hours all the days.
Thanks..
 
Launch it once in background and it will run the awk program every 2 hours forever.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Thanx a lot for the help. Just wanted to clarify since i cannot use crontab. Will manually calling the script once keep it running after every two hours.
Actually my script also includes some mailing of files after awk is performed. Will the mailing also be performed after 2 hours??
Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top