Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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/program.sh: 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

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

/Users/topher/program.sh > logfile.log

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

/Users/topher/program.sh >> logfile.log
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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .