Shell script-How to call tail then exit when 'END timestamp' appears in log?
I need to write a script that will log in to a remote server, launch a process, and then display the log output from that process and finally end the ssh session and exit the script when the process ends.
My idea for how to do this task is something like this, but I have no idea how to make it end. Code:
#! /bin/sh |
One clue might be to use --pid=$$ with tail, which causes tail to exit when pid dies. $$ is the pid of the script. Maybe pipe the tail -f to grep: | grep END && exit?
|
Thanks. Both suggestions sound like great ideas.
I would like to use --pid with tail, but the process just shows up as "perl" which is pretty generic. Here's what I see from top: Code:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND Code:
$ pgrep perl Thanks |
try using tee. It will allow you to send output to stdout and to files. You should be able to use some kind of redirection to send output to a pipe and to stdout.
|
thanks. It is good to know about tee. But I'm having trouble conceptualizing how to put all this together...
|
All times are GMT -5. The time now is 10:20 AM. |