0

I need a solution that basically tails a log file from a remote box...

  1. Works on Mac
  2. Restores itself whenever I have internet. (I frequently close and open the lid of my macbook)

It could be a script that I keep running in terminal... I just need it to always reconnect as I switch networks etc.

Some things i've tried

I wrote a script which monitors the ssh command that tails and figured I could restart it whenever the process dies... The problem is the ssh doesn't seem to actually die in the sense the process actually exits... it gets into some state where it's no longer tailing from the remote file though.

while [ 1 ]; do # timestamp ts=`date +%T` f=log.txt TEST=`ps aux | grep "[s]sh -f [email protected] tail -f /var/log/myapp/$f"` if [ "$TEST" != "" ]; then echo "$ts it's running" else echo "$ts (Re)Starting $f" ssh -f [email protected] "tail -f /var/log/myapp/$f" >> ./logs/$f fi sleep 15 done 

I thought this was the solution but didn't have any luck getting it compiled: http://www.harding.motd.ca/autossh/

2
  • 1
    Why do you want to tail a remote log file ? Perhaps there are better ways of doing what you want to do. Commented Mar 20, 2014 at 5:38
  • @Lawrence Generally it's software development. I just hate having to restart tailing all the time. It's also generally just faster if I have the info on my box when I need it... don't want to download multi gig files at once... It also is a poor mans monitoring system... I use logMX as my viewer and can setup configurable alerts. It doesn't replace things like nagios but I find there are certain events I want to monitor and no about when they occur. Commented Mar 20, 2014 at 10:22

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.