DEV Community

Eduardo Issao Ito
Eduardo Issao Ito

Posted on • Edited on

2

Bash: Monitoring a file until a string is found

The script will wait for the string "Server Started" appear in logfile.log and then continue the execution

    #!/usr/bin/env bash

    start_server.sh > logfile.log &

    # waiting for the server to start...
    ( tail -f -n0 logfile.log & ) | grep -q "Server Started"

    echo "Server is running"
Enter fullscreen mode Exit fullscreen mode

Source:
https://superuser.com/questions/270529/monitoring-a-file-until-a-string-is-found

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more