Find the answer to your Linux question:
Results 1 to 6 of 6
I have this command: Code: tail -f $TOMCAT/logs/catalina.out | grep "Server startup in" How can I stopped this when found " Server startup in " ?? thanks in advance...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48

    Stopping tail -f when certain string found


    I have this command:

    Code:
    tail -f $TOMCAT/logs/catalina.out | grep "Server startup in"
    How can I stopped this when found "Server startup in" ??

    thanks in advance

  2. #2
    Linux Guru coopstah13's Avatar
    Join Date
    Nov 2007
    Location
    NH, USA
    Posts
    3,149
    Code:
    while [ "`tail -n 1 $TOMCAT/logs/catalina.out | grep "Server startup in"`" = "" ] ; do echo `tail -n 1 test` ; done
    this is kinda crappy as it will echo a line more than once most likely, but it should work

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48
    Oh sorry. it's possible that you don't understand my question

    In a script I put this:

    STOP=`tail -f $TOMCAT/logs/catalina.out | grep "Server startup in"`
    if [ "$?" != "0" ]; then
    echo ""
    else
    echo "server start"
    fi

    I would like that tail detect a Server Start show the echo that I have into the if

  4. $spacer_open
    $spacer_close
  5. #4
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    I think youI can't proceed this way because the -f option of tail prevents it from returning.

    You should rather check for the presence of a socket file, if any, that most servers write when they are up,
    or check that the port Tomcat listens to is opened or not. See Tomcat's documentation.
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

  6. #5
    Just Joined!
    Join Date
    Oct 2008
    Posts
    48
    I try whit this:

    Code:
    tail -f $RUTA_TOMCAT/logs/catalina.out | awk '/Server startup in/; { exit }'
    I think it's run!

  7. #6
    Linux User
    Join Date
    Nov 2009
    Location
    France
    Posts
    292
    You would exit your script without any action done, what's the point ? And I'm not sure all the output of tail would be piped. Does it work as you expect ?
    0 + 1 = 1 != 2 <> 3 != 4 ...
    Until the camel can pass though the eye of the needle.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •