I decided to write down some examples of using the Unix tee command, when I manually fire off a crontab job. The cron job entry following the following format

$ ruby <script-name> >> <log-filename>
$ ruby process-entries.rb >> log-file-process.txt

When I need to run this ruby script manualy, I can use the tee command to view the log while storing a second copy to the log file as shown below.

$ ruby process-entries.rb | tee -a log-file-process.txt

Using the -a option tells tee to append to the log file instead of replacing the file.

For those working on Windows, take a look at the Gnu Utilities for Win32, which includes a tee.exe port.

Happy hacking.

– Chris


  1. Tee Command
  2. Tee Examples
  3. Tee.exe for Windows