redirect stdout/stderr within bash script

This executes the date command via shell script and logs it to the specified file with current pid.

#!/bin/bash
LOG=$$.log
exec > $LOG 2>&1
date

Post new comment

  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.
Comment