Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've inherited a complex shell script running on OSX that gets run on a crontab. Within the script I would like to periodically read everything in the terminal window and write it to another file... sort of as a log file that I can review later.

Im trying to capture things that have been ECHO'd within the script as well as any error messages displayed on the terminal. (ie /Users/topher/ line 58: Permission denied)

Is this possible? What command can read from the terminal or output of the program?

Thanks! topher

share|improve this question

I don't know about OS X's terminal application, but some terminals such as xterm can be started with an option that logs everything that appears on the display to a file. Another possibility is to run the script program, which captures all characters to and from the terminal to a file.

share|improve this answer

Use tee to output to both the screen and a file.

./some/thing | tee thing.log

You might want to redirect stderr to stdout to dump them both to the log file.

    ./some/thing 2>&1 | tee thing.log
share|improve this answer

If the command you run from cron is as following, all output generated will be written to the logfile.log file

/Users/topher/ > logfile.log

The above command will empty the logfile.log file and fill it with output generated by the script. The below command will append the output.

/Users/topher/ >> logfile.log
share|improve this answer

Your Answer


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.