Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

I'm a web developer using a MacBook Pro running OS X 10.9.3.

Before I started developing in a Mac, I used Cygwin on a Windows machine to see what was happening behind the scene on my web application. I had a Logging system built in PHP which created log files with all the content of the variables I wanted to debug.

Basically, this Logging system creates another PHP file with all the debug needed and through Cygwin, every time I refreshed my web application in the browser it would refresh itself synchronously and outputted a new print with all my recent code updates.

I've searched everywhere but didn't find any close solution.
The one I'm using right now is using the terminal and writhing:

cat /Applications/MAMP/htdocs/BO_V2/data/logs/log-2014-07-10.php 

But it is not automatic and I have to press +enter every time I want to see what the log file has to show.

On OS X, is there a way to have Terminal or another application refresh the print from my log file every time I refresh my browser window (Chrome, Firefox or Safari)?

share|improve this question
7  
The command you want is tail with the -f parameter. However this is they way to do it in Cygwin anyway. Cygwin allows the use of Unix commands on Windows - All these command are already in OSX –  Mark Jul 11 at 17:21
    
I've already tried that but it only returns the last 10 lines of code counting from the bottom. The thing about cygwin was it automatic refresh witch saved me tones of time by the end of each project –  CIRCLE Jul 11 at 17:25
3  
What command in cygwin? tail -f filename works on all the Unix systems I have used as well as Cygwin –  Mark Jul 11 at 17:26

2 Answers 2

up vote 22 down vote accepted

On windows, the Cygwin is a Unix-like environment and OS X is full on UNIX, so there is no need for any additions to get unix tools.

Open Terminal.app and start with manual pages.

The more and tail -f commands are typical unix commands to page, search, and watch a log file.

For your example, the tail command to watch your log file is:

tail -f /Applications/MAMP/htdocs/BO_V2/data/logs/log-2014-07-10.php
share|improve this answer

Assuming it's the same as on Linux, you could also use:

less /Applications/MAMP/htdocs/BO_V2/data/logs/log-2014-07-10.php

Then press Shift+F to have it tail automatically, or just Shift+G to go to the end of file.

share|improve this answer
2  
more is already less on OS X / darwin and the shift F/G commands work as advertised. –  bmike Jul 11 at 20:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.