title: How to use tee command in the crontab
body: <p>I put a job in crontab to run every 2 hours, also i want the log file of my bash output in a separate file.</p>
  
  <p><strong>Input:</strong></p>
  
  <pre><code>0 0-23/2 * * * /tmp/sample.sh | tee /tmp/logfile_extract_$(date '+%Y-%m-%d-%H').txt  
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>/bin/sh: -c: line 0: unexpected EOF while looking for matching `''
  /bin/sh: -c: line 1: syntax error: unexpected end of file
  </code></pre>