Martin Martin - 2 months ago 6x
Bash Question

How would you tail a log via a bash script without the script ending?

I have a simple script that takes a users input for a

remote host address
and then based on the selection that they make for which log they want to tail, the script will start tailing that log.


printf "\nEnter the customers Cloud URL:\n"
read -r customerURL

printf "\nWhich log do you want to tail?\n1. JLOG\n2. CLOG\n3. HLOG\n"
read -r whichlog

ssh "$customerURL"
tail -f /path/to/log

When doing this, the script runs but then once it is done SSH'ing into the host, it ends. Is what I am trying to do possible? Is there a better way to handle this?


Combine the ssh and the tail so the tail runs on the remote host instead of the local one.

ssh "$customerURL" tail -f /path/to/log