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

shell script on the command line

Status
Not open for further replies.

jerehart

Programmer
Jun 10, 1999
61
US
Hey I am trying to watch a file being written to pipe it into grep looking for a string and kill a process on that string. this is what I am doing:

tail -f some.file | grep ERROR | kill #PID

but it kills the process right away. Any ideas or need more from me?

Miah
 
hi

i don't think you can do that with tail -f and greping it with error...

what you need is a cron job which is activited a certain time to check for Error and then killing it...not a simple script like that.

hope that helps,
Hui Emagine Solutions, Inc.
 
It helps. I was trying to be lazy and hoping I could. I was afraid I would have tobulk it up. So it was not the answer I wanted but the one I thought I would get Thanks Hui

Miah
 
jerehart,

That sounds quite do-able, two questions:

1 - What's the format of the file and where do you get the PID from?

2 - What tools do you have? Perl? Awk? Ksh? Mike
michael.j.lacey@ntlworld.com
Email welcome if you're in a hurry or something -- but post in tek-tips as well please, and I will post my reply here as well.
 
Mike,

the file format is just a text ascii file nothing special. I get the PID from
ps -elf | grep <The process name>

I would use perl myself I like it a lot more than anything else. I have awk and tcl available but don't like them too much but could do it in all.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top